QuakeForge  0.7.2.210-815cf
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages

Functions

int UDP_AddrCompare (netadr_t *addr1, netadr_t *addr2)
 Compare two network addresses. More...
 
const char * UDP_AddrToString (netadr_t *addr)
 Convert an address to a string. More...
 
int UDP_Broadcast (int socket, byte *buf, int len)
 Broadcast a packet via the specified socket. More...
 
int UDP_CheckNewConnections (void)
 Check for incoming packets on the accept socket. More...
 
int UDP_CloseSocket (int socket)
 Close a socket. More...
 
int UDP_Connect (int socket, netadr_t *addr)
 Does very little. More...
 
int UDP_GetAddrFromName (const char *name, netadr_t *addr)
 Convert a human readable address to a quake address. More...
 
int UDP_GetNameFromAddr (netadr_t *addr, char *name)
 Convert an address to a hostname. More...
 
int UDP_GetSocketAddr (int socket, netadr_t *addr)
 Retrieve the address to which the socket is bound. More...
 
int UDP_GetSocketPort (netadr_t *addr)
 Get the port number from the socket address. More...
 
int UDP_Init (void)
 Initialize the UDP network interface. More...
 
void UDP_Listen (qboolean state)
 Open or close the accept socket. More...
 
int UDP_OpenSocket (int port)
 Open a single socket on the specified port. More...
 
int UDP_Read (int socket, byte *buf, int len, netadr_t *addr)
 Read a packet from the specified socket. More...
 
int UDP_SetSocketPort (netadr_t *addr, int port)
 Set the port number of the socket address. More...
 
void UDP_Shutdown (void)
 Shutdown the UDP network interface. More...
 
int UDP_Write (int socket, byte *buf, int len, netadr_t *addr)
 Send a packet via the specified socket to the specified address. More...
 

Detailed Description

Function Documentation

int UDP_AddrCompare ( netadr_t addr1,
netadr_t addr2 
)

Compare two network addresses.

Compare the port number too.

Parameters
addr1The first address to compare.
addr2The second address to compare.
Returns
-2 if the family is different.
-1 if the family is the same, but the address is different.
1 if the family and address are the same, but the port is different.
0 if everything is the same.
const char* UDP_AddrToString ( netadr_t addr)

Convert an address to a string.

Include the port number in the string.

Warning
The return value is a pointer to a static buffer. The returned string must be saved if mixing calls with different addresses.
Parameters
addrThe address to convert.
Returns
The address in human readable form.
int UDP_Broadcast ( int  socket,
byte buf,
int  len 
)

Broadcast a packet via the specified socket.

Warning
It is a fatal error to use more than one socket for broadcasting.
Parameters
socketThe socket via which the packet will be broadcast.
bufThe packet data to be sent.
lenThe number of bytes in the packet.
Returns
The number of bytes sent or -1 on error.
int UDP_CheckNewConnections ( void  )

Check for incoming packets on the accept socket.

Checks if any packets are available on net_acceptsocket.

int UDP_CloseSocket ( int  socket)

Close a socket.

Parameters
socketThe socket to close.
Returns
0 for success, -1 for failure.
int UDP_Connect ( int  socket,
netadr_t addr 
)

Does very little.

Parameters
socketThe socket on which to do very little.
addrThe address to which very little will be done.
Returns
0
int UDP_GetAddrFromName ( const char *  name,
netadr_t addr 
)

Convert a human readable address to a quake address.

Accepts both host names (full or partial) and numeric form.

The port address can be specified when using a numeric address.

Numeric addresses can be partial: unspecified portions are filled out using the network address of the socket.

Parameters
nameThe human readable address to be converted.
addrThe resulting address of the conversion.
Returns
0 if the conversion is successful, otherwise -1.
int UDP_GetNameFromAddr ( netadr_t addr,
char *  name 
)

Convert an address to a hostname.

Parameters
[in]addrThe address to covert.
[out]nameOutput buffer for the hostname.
Bug:
No checking is done on the size of the buffer, and uses strcpy.
int UDP_GetSocketAddr ( int  socket,
netadr_t addr 
)

Retrieve the address to which the socket is bound.

Parameters
socketThe socket for which the address will be retrieved.
[out]addrThe address to which the socket is bound.
Returns
0
int UDP_GetSocketPort ( netadr_t addr)

Get the port number from the socket address.

Parameters
addrThe socket address from which to retrieve the port number.
Returns
The port number.
int UDP_Init ( void  )

Initialize the UDP network interface.

Opens a single control socket.

Returns
The control socket or -1 on failure.
void UDP_Listen ( qboolean  state)

Open or close the accept socket.

Sets net_acceptsocket to the socket number or -1. The accept socket is stored in net_hostport.

Parameters
stateTrue to open the socket, false to close it.
int UDP_OpenSocket ( int  port)

Open a single socket on the specified port.

If port is 0, then use the operating system default.

Parameters
portThe port on which to open the socket.
Returns
The socket number or -1 on failure.
int UDP_Read ( int  socket,
byte buf,
int  len,
netadr_t addr 
)

Read a packet from the specified socket.

Parameters
socketThe socket from which the packet will be read.
bufThe buffer into which the packet will be read.
lenThe maximum number of bytes to read.
[out]addrThe address from which the packet originated.
Returns
The number of bytes read or -1 on error.
int UDP_SetSocketPort ( netadr_t addr,
int  port 
)

Set the port number of the socket address.

Parameters
addrThe socket address which to will have its port number set.
portThe port number to which the socket address will be set.
Returns
0
void UDP_Shutdown ( void  )

Shutdown the UDP network interface.

int UDP_Write ( int  socket,
byte buf,
int  len,
netadr_t addr 
)

Send a packet via the specified socket to the specified address.

Parameters
socketThe socket via which the packet will be sent.
bufThe packet data to be sent.
lenThe number of bytes in the packet.
addrThe addres to which the packet will be sent.
Returns
The number of bytes sent or -1 on error.