This wiki is archived and useful information is being migrated to the main bzflag.org website
Difference between revisions of "Network Protocol"
m (NetworkProtocol moved to Network Protocol) |
m (be more verbose) |
||
Line 9: | Line 9: | ||
The [http://bzflag.svn.sourceforge.net/viewvc/*checkout*/bzflag/trunk/bzflag/misc/bzfquery.php bzfquery.php script] is a nice example of how to connect to a server. | The [http://bzflag.svn.sourceforge.net/viewvc/*checkout*/bzflag/trunk/bzflag/misc/bzfquery.php bzfquery.php script] is a nice example of how to connect to a server. | ||
− | At the beginning you need to open a socket using the TCP/IP protocol. Beginning with protocol 0048 you need to send "BZFLAG\r\n\r\n" in order to get any reply. At that time you unfortunately don't know the protocol, so send it by default or your | + | At the beginning you need to open a socket using the TCP/IP protocol. Beginning with protocol 0048 you need to send "BZFLAG\r\n\r\n" in order to get any reply. At that time you unfortunately don't know the protocol, so send it by default or your client will probably freeze. |
Then you will get 9 bytes from the socket: First the string "BZFS" and then a 4 digit protocol number. If the protocol is newer or equal to 0048 your established connection is fine. If it is older than 0048 your client has been kicked, in this case you need to reconnect again without sending "BZFLAG\r\n\r\n". | Then you will get 9 bytes from the socket: First the string "BZFS" and then a 4 digit protocol number. If the protocol is newer or equal to 0048 your established connection is fine. If it is older than 0048 your client has been kicked, in this case you need to reconnect again without sending "BZFLAG\r\n\r\n". | ||
+ | |||
+ | Server owners will see something like the following in the logs if their server(s) use a protocol older than 0048: | ||
+ | Player [0] sent huge packet length (len=16986), possible attack | ||
+ | Player [0] removed at 2007-04-11 15:52:55: large packet recvd | ||
[[Category:Concepts]] | [[Category:Concepts]] |
Revision as of 14:03, 11 April 2007
This page describes the used networking protocol of BZFlag.
Platform differences
The network protocol is cross platform, however implementation of sockes is different on the platforms. *nix, Linux and Mac OS X use BSD sockets, Windows® uses WinSock. WinSock is not 100% compatible to the standard therefore if you use a low level language you need different code for Windows® to do the same like on other platforms.
Connecting to a server
The bzfquery.php script is a nice example of how to connect to a server.
At the beginning you need to open a socket using the TCP/IP protocol. Beginning with protocol 0048 you need to send "BZFLAG\r\n\r\n" in order to get any reply. At that time you unfortunately don't know the protocol, so send it by default or your client will probably freeze.
Then you will get 9 bytes from the socket: First the string "BZFS" and then a 4 digit protocol number. If the protocol is newer or equal to 0048 your established connection is fine. If it is older than 0048 your client has been kicked, in this case you need to reconnect again without sending "BZFLAG\r\n\r\n".
Server owners will see something like the following in the logs if their server(s) use a protocol older than 0048:
Player [0] sent huge packet length (len=16986), possible attack Player [0] removed at 2007-04-11 15:52:55: large packet recvd