This page describes the used networking protocol of BZFlag.
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  sent huge packet length (len=16986), possible attack Player  removed at 2007-04-11 15:52:55: large packet recvd