Sending Integers with Winsock
Hey, I'm once again back to the multiplayer forums. I'm hoping to make a small MUD as my next project after I release my current one. I've gotten the basics of Winsock down with Mud Pies part one. I have decided I am going to go out on my own making the FSM, etc instead of copying-pasting the stuff from Mud Pies 2. One main question I have: Is it possible to send int's with Winsock? Thanks, and maybe expect some more questions after this.
What language is it in (since you mention Winsock I assume its a real language and not some engine scripting language...)
In C/C++ you can copy memory into the packet buffer. The memory could be a STRUCT which can contain any data you want. You could cast a pointer to an INT or array of INT as pointer to void and use it to copy mem (there could be a problem if the plaforms on each end have a big endian/little endian difference).
I have pushed integers as strings in Visual Basic thru a TCP pipe -- using fixed format of digits (usually when needing 1 2 3 digits for message values
You can send any binary data that you can memcpy(). The sendto() and send() functions are very similar to write() and memcpy() in how they handle the data you pass to it.
However, if you want your MUD to be accessed by a telnet client, then you cannot send binary data, because telnet clients expect the telnet protocol, which is plain text plus some control sequences to negotiate the connection.
However, if you want your MUD to be accessed by a telnet client, then you cannot send binary data, because telnet clients expect the telnet protocol, which is plain text plus some control sequences to negotiate the connection.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement