2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
net_dgrm.h
|
|
|
|
|
|
|
|
@description@
|
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-07-26 05:15:41 +00:00
|
|
|
/** \defgroup nq-dgrm NetQuake Datagram network driver.
|
|
|
|
\ingroup nq-nd
|
|
|
|
*/
|
|
|
|
//@{
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2011-08-02 06:22:33 +00:00
|
|
|
/** Initialize the Datagram net driver.
|
|
|
|
|
|
|
|
Also initializes the underlying lan drivers.
|
|
|
|
|
|
|
|
\return 0 if successful, otherwise -1.
|
|
|
|
*/
|
2001-02-19 21:15:25 +00:00
|
|
|
int Datagram_Init (void);
|
2011-08-02 06:22:33 +00:00
|
|
|
|
|
|
|
/** Control the listen status of the underlying lan drivers.
|
|
|
|
|
|
|
|
\param state True to enable, false to disable.
|
|
|
|
*/
|
2001-02-19 21:15:25 +00:00
|
|
|
void Datagram_Listen (qboolean state);
|
2011-08-02 06:22:33 +00:00
|
|
|
|
|
|
|
/** Search for hosts (servers) on the local network.
|
|
|
|
|
|
|
|
If \p xmit is true, broadcast a CCREQ_SERVER_INFO packet via all
|
|
|
|
underlying lan drivers using their control ports.
|
|
|
|
|
|
|
|
Check for any CCREP_SERVER_INFO responses. Ignore all other packets.
|
|
|
|
|
|
|
|
\param xmit True to send the broadcast, falst to only listen.
|
|
|
|
*/
|
2001-02-19 21:15:25 +00:00
|
|
|
void Datagram_SearchForHosts (qboolean xmit);
|
2011-08-02 06:22:33 +00:00
|
|
|
|
|
|
|
/** Connect to the specified host.
|
|
|
|
|
|
|
|
\param host The host to which the connection will be made.
|
|
|
|
\return A pointer to the socket representing the connection, or
|
|
|
|
null if unsuccessful.
|
|
|
|
*/
|
2001-07-15 07:04:17 +00:00
|
|
|
qsocket_t *Datagram_Connect (const char *host);
|
2011-08-02 06:22:33 +00:00
|
|
|
|
|
|
|
/** Check for a new incoming connection.
|
|
|
|
|
|
|
|
\return A pointer to the socekt representing the new connection,
|
|
|
|
or null if none found.
|
|
|
|
*/
|
2001-02-19 21:15:25 +00:00
|
|
|
qsocket_t *Datagram_CheckNewConnections (void);
|
2011-08-02 06:22:33 +00:00
|
|
|
|
|
|
|
/** Check for and process an incoming packet on the socket.
|
|
|
|
|
|
|
|
\param sock The socket to check.
|
|
|
|
\return -1 if there is an error
|
|
|
|
\return 0 if the packet is stale
|
|
|
|
\return 1 if the packet is reliable
|
|
|
|
\return 2 if the packet is unreliable
|
|
|
|
*/
|
2001-02-19 21:15:25 +00:00
|
|
|
int Datagram_GetMessage (qsocket_t *sock);
|
2011-08-02 06:22:33 +00:00
|
|
|
|
|
|
|
/** Send a reliable packet to the socket.
|
|
|
|
|
|
|
|
\param sock The socket to which the packet will be sent.
|
|
|
|
\param data The packet to be sent.
|
|
|
|
\return -1 If there is an error
|
|
|
|
\return 1 if everything is ok.
|
|
|
|
*/
|
2001-02-19 21:15:25 +00:00
|
|
|
int Datagram_SendMessage (qsocket_t *sock, sizebuf_t *data);
|
2011-08-02 06:22:33 +00:00
|
|
|
|
|
|
|
/** Send an unreliable packet to the socket.
|
|
|
|
|
|
|
|
\param sock The socket to which the packet will be sent.
|
|
|
|
\param data The packet to be sent.
|
|
|
|
\return -1 If there is an error
|
|
|
|
\return 1 if everything is ok.
|
|
|
|
*/
|
2001-02-19 21:15:25 +00:00
|
|
|
int Datagram_SendUnreliableMessage (qsocket_t *sock, sizebuf_t *data);
|
2011-08-02 06:22:33 +00:00
|
|
|
|
|
|
|
/** Check if a reliable message can be sent to the socket.
|
|
|
|
|
|
|
|
\param sock The socket to check.
|
|
|
|
\return True if the packet can be sent.
|
|
|
|
*/
|
2001-02-19 21:15:25 +00:00
|
|
|
qboolean Datagram_CanSendMessage (qsocket_t *sock);
|
2011-08-02 06:22:33 +00:00
|
|
|
|
|
|
|
/** Check if an unreliable message can be sent to the socket.
|
|
|
|
|
|
|
|
Always true.
|
|
|
|
|
|
|
|
\param sock The socket to check.
|
|
|
|
\return True if the packet can be sent.
|
|
|
|
*/
|
2001-02-19 21:15:25 +00:00
|
|
|
qboolean Datagram_CanSendUnreliableMessage (qsocket_t *sock);
|
2011-08-02 06:22:33 +00:00
|
|
|
|
|
|
|
/** Close the socket.
|
|
|
|
|
|
|
|
\param sock The socket to close.
|
|
|
|
*/
|
2001-02-19 21:15:25 +00:00
|
|
|
void Datagram_Close (qsocket_t *sock);
|
2011-08-02 06:22:33 +00:00
|
|
|
|
|
|
|
/** Shutdown the Datagram net driver.
|
|
|
|
*/
|
2001-02-19 21:15:25 +00:00
|
|
|
void Datagram_Shutdown (void);
|
2011-07-26 05:15:41 +00:00
|
|
|
|
|
|
|
//@}
|