net.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef void stream_callback_func (struct net_stream *s)
typedef void datagram_callback_func (struct datagram_socket *s, const char *buf, int len, struct sockaddr *from)

Functions

qboolean SV_Start (const char *node, const char *service, stream_callback_func *func)
void SV_Stop (void)
struct datagram_socketNET_DatagramSocketNew (const char *node, const char *service, datagram_callback_func *datagram_func)
 Opens a datagram socket (UDP).
void NET_DatagramSend (struct datagram_socket *s, const char *buf, int len, struct sockaddr *to)
void NET_DatagramBroadcast (struct datagram_socket *s, const char *buf, int len, int port)
void NET_DatagramSocketClose (struct datagram_socket *s)
void NET_SockaddrToStrings (struct datagram_socket *s, struct sockaddr *addr, char *node, size_t nodelen, char *service, size_t servicelen)
 Convert sockaddr to string.
void NET_Init (void)
void NET_Shutdown (void)
void NET_Wait (int timeout)
struct net_streamNET_Connect (const char *node, const char *service)
 Try to connect to a given host on a given port.
struct net_streamNET_ConnectToLoopBack (void)
void NET_StreamEnqueue (struct net_stream *s, const char *data, int len)
 Enqueue a network message into a stream.
qboolean NET_StreamIsClosed (struct net_stream *s)
int NET_StreamGetLength (struct net_stream *s)
int NET_StreamPeek (struct net_stream *s, char *data, int len)
 Returns the length of the waiting inbound buffer.
int NET_StreamDequeue (struct net_stream *s, char *data, int len)
void * NET_StreamGetData (struct net_stream *s)
void NET_StreamSetData (struct net_stream *s, void *data)
const char * NET_StreamPeerToName (struct net_stream *s, char *dst, int len, qboolean appendPort)
qboolean NET_StreamIsLoopback (struct net_stream *s)
void NET_StreamFree (struct net_stream *s)
 Call NET_StreamFree to dump the whole thing right now.
void NET_StreamFinished (struct net_stream *s)
 Call NET_StreamFinished to mark the stream as uninteresting, but to finish sending any data in the buffer. The stream will appear closed after this call, and at some unspecified point in the future s will become an invalid pointer, so it should not be further referenced.
void NET_StreamSetCallback (struct net_stream *s, stream_callback_func *func)

Detailed Description

Definition in file net.h.


Typedef Documentation

typedef void datagram_callback_func(struct datagram_socket *s, const char *buf, int len, struct sockaddr *from)

Definition at line 32 of file net.h.

typedef void stream_callback_func(struct net_stream *s)

Definition at line 31 of file net.h.


Function Documentation

struct net_stream* NET_Connect ( const char *  node,
const char *  service 
) [read]

Try to connect to a given host on a given port.

Parameters:
[in] node The host to connect to
[in] service The port to connect to
See also:
NET_DoConnect
NET_ConnectToLoopBack
Todo:
What about a timeout

Definition at line 622 of file net.c.

References AI_ADDRCONFIG, AI_NUMERICSERV, Com_Printf(), net_stream::index, cvar_s::integer, NET_DoConnect(), and NET_StreamGetFree().

Referenced by CL_Connect(), CL_PingServer(), CL_Rcon_f(), CL_ServerInfo_f(), and Irc_Net_Connect().

struct net_stream* NET_ConnectToLoopBack ( void   )  [read]
void NET_DatagramBroadcast ( struct datagram_socket s,
const char *  buf,
int  len,
int  port 
)
See also:
NET_DatagramSend
NET_DatagramSocketNew
Todo:
This is only sending on the first available device, what if we have several devices?

Definition at line 1098 of file net.c.

References Com_Error(), ERR_DROP, datagram_socket::family, and NET_DatagramSend().

Referenced by CL_PingServers_f().

void NET_DatagramSend ( struct datagram_socket s,
const char *  buf,
int  len,
struct sockaddr *  to 
)
void NET_DatagramSocketClose ( struct datagram_socket s  ) 
struct datagram_socket* NET_DatagramSocketNew ( const char *  node,
const char *  service,
datagram_callback_func func 
) [read]

Opens a datagram socket (UDP).

See also:
NET_DatagramSocketDoNew
Parameters:
[in] node The numeric address to resolv (might be NULL)
[in] service The port number
[in] func Callback function for data handling

Definition at line 1038 of file net.c.

References AI_ADDRCONFIG, AI_NUMERICSERV, Com_Printf(), datagram_socket::func, cvar_s::integer, NET_DatagramSocketDoNew(), and qfalse.

Referenced by CL_PingServers_f(), and SV_InitGame().

void NET_Init ( void   ) 
void NET_Shutdown ( void   ) 
See also:
NET_Init

Definition at line 323 of file net.c.

References dbuffer_shutdown().

void NET_SockaddrToStrings ( struct datagram_socket s,
struct sockaddr *  addr,
char *  node,
size_t  nodelen,
char *  service,
size_t  servicelen 
)

Convert sockaddr to string.

Parameters:
[in] s The datagram socket type to get the addrlen from
[in] addr The socket address to convert into a string
[out] node The target node name buffer
[in] nodelen The length of the node name buffer
[out] service The target service name buffer
[in] servicelen The length of the service name buffer

Definition at line 1151 of file net.c.

References datagram_socket::addrlen, Com_Printf(), and Q_strncpyz().

Referenced by CL_ServerListDiscoveryCallback().

int NET_StreamDequeue ( struct net_stream s,
char *  data,
int  len 
)
void NET_StreamEnqueue ( struct net_stream s,
const char *  data,
int  len 
)
void NET_StreamFinished ( struct net_stream s  ) 

Call NET_StreamFinished to mark the stream as uninteresting, but to finish sending any data in the buffer. The stream will appear closed after this call, and at some unspecified point in the future s will become an invalid pointer, so it should not be further referenced.

Definition at line 785 of file net.c.

References dbuffer_len, net_stream::finished, free_dbuffer(), net_stream::inbound, net_stream::loopback_peer, NET_StreamClose(), net_stream::outbound, qtrue, read_fds, and net_stream::socket.

Referenced by CL_Disconnect(), SV_DropClient(), and SV_FinalMessage().

void NET_StreamFree ( struct net_stream s  ) 

Call NET_StreamFree to dump the whole thing right now.

See also:
NET_StreamClose
NET_StreamFinished

Definition at line 770 of file net.c.

References net_stream::finished, NET_StreamClose(), and qtrue.

Referenced by CL_PingServerCallback(), CL_RconCallback(), CL_ServerInfoCallback(), Irc_Net_Connect(), Irc_Net_Disconnect(), NET_StreamNew(), and SV_ReadPacket().

void* NET_StreamGetData ( struct net_stream s  ) 

Definition at line 753 of file net.c.

References net_stream::data.

Referenced by CL_PingServerCallback(), and SV_ReadPacket().

int NET_StreamGetLength ( struct net_stream s  ) 

Definition at line 721 of file net.c.

References dbuffer_len, and net_stream::inbound.

Referenced by NET_ReadMsg(), and NET_Wait().

qboolean NET_StreamIsClosed ( struct net_stream s  ) 

Definition at line 716 of file net.c.

References net_stream::closed, net_stream::finished, and qtrue.

qboolean NET_StreamIsLoopback ( struct net_stream s  ) 

Definition at line 853 of file net.c.

References net_stream::loopback.

Referenced by CL_ConnectionlessPacket(), and NET_StreamPeerToName().

int NET_StreamPeek ( struct net_stream s,
char *  data,
int  len 
)

Returns the length of the waiting inbound buffer.

See also:
dbuffer_get

Definition at line 730 of file net.c.

References net_stream::closed, dbuffer_get(), dbuffer_len, net_stream::finished, and net_stream::inbound.

Referenced by NET_ReadMsg().

const char* NET_StreamPeerToName ( struct net_stream s,
char *  dst,
int  len,
qboolean  appendPort 
)
Parameters:
[in] s The network stream to get the name for
[out] dst The target buffer to store the ip and port in
[in] len The length of the target buffer
[in] appendPort Also append the port number to the target buffer

Definition at line 814 of file net.c.

References net_stream::addrlen, Com_Printf(), Com_sprintf(), NET_StreamIsLoopback(), Q_strncpyz(), and net_stream::socket.

Referenced by CL_ServerInfoCallback(), NET_ShowStreams_f(), NET_Wait(), SV_ConnectionlessPacket(), SV_Status_f(), SVC_DirectConnect(), and SVC_RemoteCommand().

void NET_StreamSetCallback ( struct net_stream s,
stream_callback_func func 
)

Definition at line 846 of file net.c.

References net_stream::func.

Referenced by CL_PingServer(), CL_Rcon_f(), and CL_ServerInfo_f().

void NET_StreamSetData ( struct net_stream s,
void *  data 
)

Definition at line 758 of file net.c.

References net_stream::data.

Referenced by CL_PingServer(), and SVC_DirectConnect().

void NET_Wait ( int  timeout  ) 
qboolean SV_Start ( const char *  node,
const char *  service,
stream_callback_func func 
)
See also:
NET_DoStartServer
Parameters:
[in] node The node to start the server with
[in] service If this is NULL we are in single player mode
[in] func The server callback function to read the packets
See also:
SV_ReadPacket
server_func
SV_Stop

Definition at line 912 of file net.c.

References AI_ADDRCONFIG, AI_NUMERICSERV, Com_Printf(), cvar_s::integer, INVALID_SOCKET, NET_DoStartServer(), qfalse, qtrue, server_func, server_running, and server_socket.

Referenced by SV_InitGame().

void SV_Stop ( void   ) 
See also:
SV_Start

Definition at line 961 of file net.c.

References INVALID_SOCKET, netCloseSocket, qfalse, read_fds, server_func, server_running, and server_socket.

Referenced by SV_Shutdown().


Generated by  doxygen 1.6.2