• Welcome to Valhalla Legends Archive.
 

[C++] I don't want it!

Started by Sorc.Polgara, March 21, 2005, 10:28 AM

Previous topic - Next topic

Sorc.Polgara

The optional packets like 0x25 and 0x59 that you do not have to respond are a pain.

Ok, I want to filter these damn packets so that I can receive what I the packet(s) that I really need.

Lets just say, I send 0x50.  Then BNet sends me the 0x25 packet.  Then I receive the 0x50 response.

In C++ I have to call recv() and it gets the packet that is sent to me.  I am sent to 0x25 which I do not want.  And basically I have to call recv() two freaking times to actually get the 0x50 response, the data that I really need.

Is there a better way than calling recv() two times just to filter out the 0x25 or 0x59 and get the packet response that I need?

Networks

why can't you do a simple if statement?
if (packet_id != 0x25 || packet_id != 0x59)
{
  // parsing function here
}

OnlyMeat

TCP/IP is a sequential protocol, which means you receive the packets in the same order they were sent. So to access the next data chunk on the network stack, you must first pop the chunk before it.

Thats atleast the way i think of it, although it's not really a stack specifically as stacks work on a LIFO basis. It's more of a queue type FIFO system.

iago

Quote from: OnlyMeat on March 21, 2005, 11:15 AM
TCP/IP is a sequential protocol, which means you receive the packets in the same order they were sent. So to access the next data chunk on the network stack, you must first pop the chunk before it.

Thats atleast the way i think of it, although it's not really a stack specifically as stacks work on a LIFO basis. It's more of a queue type FIFO system.

You have the definition of the TCP/IP stack wrong.  The "stack" is referring to the network layers (physical, data link, address, transport, etc) (yes, I know I call them by the wrong name).  The right term is a "stream".

Anyway, Networks is right, just ignore it if you don't want it.  Calling recv() twice isn't the most horrible thing ever.

You shouldn't actually be depending on the order that stuff is received.  Doing that is a very ba idea.  You should have a single recv() and an event processor.  Don't bother calling any functions if it's not a useful packet.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*



iago

I'm not really sure what you're talking about, but I'll assume it's directed at my last comment.  I don't consider Battle.net to be a finite state machine, except in a few cases.  There are very few packets that have a defined order, though, and it's normally not a good idea to assume that there are any "states".  The real clients don't (as far as I remember) except for "logged in" and "not logged in". 
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


UserLoser.

Quote from: iago on March 21, 2005, 02:32 PM
I'm not really sure what you're talking about, but I'll assume it's directed at my last comment.  I don't consider Battle.net to be a finite state machine, except in a few cases.  There are very few packets that have a defined order, though, and it's normally not a good idea to assume that there are any "states".  The real clients don't (as far as I remember) except for "logged in" and "not logged in". 

IIRC, War3's Game.dll holds different states such as in chat, not in chat, in game, changing pssword, logging on, will flood off, and stuff like that

iago

Quote from: UserLoser on March 21, 2005, 02:53 PM
Quote from: iago on March 21, 2005, 02:32 PM
I'm not really sure what you're talking about, but I'll assume it's directed at my last comment.  I don't consider Battle.net to be a finite state machine, except in a few cases.  There are very few packets that have a defined order, though, and it's normally not a good idea to assume that there are any "states".  The real clients don't (as far as I remember) except for "logged in" and "not logged in". 

IIRC, War3's Game.dll holds different states such as in chat, not in chat, in game, changing pssword, logging on, will flood off, and stuff like that

That's still a pretty crappy FSM.

In any case, I don't see how that has anything to do with the original problem.
This'll make an interesting test for broken AV:
QuoteX5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*


MyndFyre

Quote from: Banana fanna fo fanna on March 21, 2005, 11:44 AM
You may be interested in http://en.wikipedia.org/wiki/Finite_state_machine

Perhaps, but SID_PING and SID_REGISTEREMAIL (that's 0x59 right?) don't actually change the state of the client.  They can change the state of the user's representation on the server, that's all.

The state that IS changed via these packets is whether the machine (client) is processing these packets or receiving more data or whatnot.
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

Arta

Battle.net has several states, although they may not be explicit, and oftentimes there are several ways to move between states. I think an FSM could be useful to someone that likes FSMs.

Examples:

Connected, but no key data
Key data sent, but not logon - the interactions between these states would depend on your pruduct (WAR3: dull, DRTL: interesting)
Logon, but not in chat
In chat
Out of chat, but not in a game
in a game, and out of chat
in a game and in chat (An unreachable state, hopefully!)

Another thing I just realised: certain messages are permitted only in specific states. That could be important to someone who wanted to consider that in their design.

Anyway, all I'm trying to say is, the simplicity of a system doesn't negate the usefulness of modelling it, especially if you don't know about the system and you're trying to get a better understanding of it.

Adron

Quote from: Arta[vL] on March 21, 2005, 06:18 PM
Anyway, all I'm trying to say is, the simplicity of a system doesn't negate the usefulness of modelling it, especially if you don't know about the system and you're trying to get a better understanding of it.

Plus, as soon as you drop multiple threads for a multi-bot program, you're actively developing state machines and tracking the state yourself...

Hdx

Quote from: Arta[vL] on March 21, 2005, 06:18 PM
in a game and in chat (An unreachable state, hopefully!)
Hurm, It is possible.. And has been done...
~-~(HDX)~-~

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

Eric

#12
Quote from: HdxBmx27 on March 22, 2005, 04:12 PM
Quote from: Arta[vL] on March 21, 2005, 06:18 PM
in a game and in chat (An unreachable state, hopefully!)
Hurm, It is possible.. And has been done...
~-~(HDX)~-~

Once you join or create a game, you are removed from the chatting environment, so no, it hasn't been done.  It's impossible.

Hdx

#13
Well If your running through D2GS then no, Login to a realm game, and you can still chat in normal channels. The actual client manually leaves the chat when joining games.
But for D1, your right it is impossible. Hurm, I believe it is possible to be in a game, yet still be chatting with SC to...
~-~(HDX)~-~

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

Eric

#14
Quote from: HdxBmx27 on March 22, 2005, 04:28 PM
Well If your running through D2GS then no, Login to a realm game, and you can still chat in normal channels. The avually client manually leaves the chat when joining games.
But for D1, your right it is impossible. Hurm, I bleave it is possible to be in a game, yet still be chatting with SC to...
~-~(HDX)~-~

You can join a game without informing Battle.net, but if you do that, your Battle.net status will not change.