VG3_nw_connect()
Connect to network-server.SYNTAX
int
VG3_nw_connect(struct vg3_nwclient *nwclnt,
const char *ipaddr,
const char *svport,
const char *name,
int maxcli,
int *masterbyte)
FUNCTION PARAMETERS
nwclnt | Network-struct |
ipaddr | IP address of network-server |
svport | UDP port of network-server or NULL = default port |
name | Name of client for identification or NULL = hostname |
maxcli | Maximal number of clients to connect or 0 = no matter |
masterbyte | Whether client is master-client: 0 = no master, 1 to 255 = master There should be at least one master. Only the master can stop waiting for connnections and start the game, if it is not started automatically because maxcli clients has been connected. The value of the masterbyte will be sent to all clients, this is a rudimentary way to pass settings to the clients. When the game has begun, the master becomes irrelevant. If there are more than one master, the first connected will win. |
RETURN VALUE
Returns the client-number on success,
or 0 on exiting-request: close window and exit the game
or -1 on failure.
ERRORS
On error VG3_errmsg() returns:
EINVAL - error in argument
ENOTCONN - cannot connect to network-server
EIO - error sending to or receiving from network-server
DESCRIPTION
Connect to the network-server.
Before connecting the keys have to be defined with VG3_nw_addkey().
The returned client-number can be used to distinguish
the local player from the other network players.
The client-numbers begin with 1.
After connecting the network-server will go into the main receiving-sending loop
with a timeout of 60 seconds.
This means that the functions VG3_nw_update() or VG3_nw_recv_data()
must be at least called once by any client within this time.
SEE ALSO