Overview -------- Use the tcp/ip network functions for multiplayer games. There is further information in Initializing and ending functions. When using network, there must be one master player, who starts the network server (start_nettcp()). All players (including the master player) then connect to the network server (connect_nettcp()), where they get back some information - about number of players, their own player number and a general network memory containing data of each player they share. While the game loop, they call talk_nettcp() once per loop or better less often (e.g. once per 3 loops), to actualize information about the other players. talk_nettcp() acts synchronously, that means, waits for every player sending network information. When a player ends, he calls close_nettcp() to disconnect from the network server - which exits when all players are disconnected. The functions ------------- for start_nettcp() please see Initializing and ending functions. for connect_nettcp() please see Initializing and ending functions. int talk_nettcp(): send the players data field to the network server and receive all data fields of the other players. This function can be called less than once per game loop, when generating too much network traffic and slowing down the game. Return value: 0=OK -1=error (which means, you are disconnected) Example: if (talk_nettcp()==-1) { [...error...] } for close_nettcp() please see Initializing and ending functions.
Home | Previous: Sound functions | Next: Other functions and programs