# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

NLNET::CUdpSock Class Reference

CUdpSock: Unreliable datagram socket via UDP. More...

#include <udp_sock.h>

Inheritance diagram for NLNET::CUdpSock:

NLNET::CSock List of all members.

Public Methods

Socket setup
 CUdpSock (bool logging=true)
 Constructor. More...

void bind (uint16 port)
 Binds the socket to the specified port. More...

void bind (const CInetAddress &addr)
 Same as bind(uint16) but binds on a specified address/port (useful when the host has several addresses). More...

Receiving data
bool receive (uint8 *buffer, uint32 &len, bool throw_exception=true)
 Receives data from the peer. More...

bool receivedFrom (uint8 *buffer, uint &len, CInetAddress &addr, bool throw_exception=true)
 Receives data and say who the sender is. More...

Sending data
void sendTo (const uint8 *buffer, uint len, const CInetAddress &addr)
 Sends data to the specified host (unreliable sockets only). More...


Private Attributes

bool _Bound
 True after calling bind() or sendTo(). More...


Detailed Description

CUdpSock: Unreliable datagram socket via UDP.

See base class CSock.

Author:
Olivier Cado , Nevrax France
Date:
2000-2001

Definition at line 42 of file udp_sock.h.


Constructor & Destructor Documentation

NLNET::CUdpSock::CUdpSock bool    logging = true
 

Constructor.

Parameters:
logging  Disable logging if the server socket object is used by the logging system, to avoid infinite recursion

Definition at line 62 of file udp_sock.cpp.

References NLNET::CSock::createSocket.


Member Function Documentation

void NLNET::CUdpSock::bind const CInetAddress   addr
 

Same as bind(uint16) but binds on a specified address/port (useful when the host has several addresses).

Definition at line 86 of file udp_sock.cpp.

References _Bound, NLNET::CSock::_LocalAddr, NLNET::CSock::_Sock, addr, nldebug, and value.

void NLNET::CUdpSock::bind uint16    port
 

Binds the socket to the specified port.

Call bind() for an unreliable socket if the host acts as a server and expects to receive messages. If the host acts as a client, call directly sendTo(), in this case you need not bind the socket.

Definition at line 74 of file udp_sock.cpp.

References addr, and NLNET::CSock::setLocalAddress.

bool NLNET::CUdpSock::receive uint8   buffer,
uint32   len,
bool    throw_exception = true
 

Receives data from the peer.

(blocking function) The socket must be pseudo-connected.

Reimplemented from NLNET::CSock.

Definition at line 156 of file udp_sock.cpp.

References NLNET::CSock::_BytesReceived, NLNET::CSock::_Connected, NLNET::CSock::_RemoteAddr, NLNET::CSock::_Sock, nlassert, and nldebug.

bool NLNET::CUdpSock::receivedFrom uint8   buffer,
uint   len,
CInetAddress   addr,
bool    throw_exception = true
 

Receives data and say who the sender is.

(blocking function) The socket must have been bound before, by calling either bind() or sendTo().

Parameters:
buffer  [in] Address of buffer
len  [in/out] Requested length of buffer, and actual number of bytes received
addr  [out] Address of sender

Definition at line 183 of file udp_sock.cpp.

References NLNET::CSock::_BytesReceived, NLNET::CSock::_Sock, addr, and nldebug.

void NLNET::CUdpSock::sendTo const uint8   buffer,
uint    len,
const CInetAddress   addr
 

Sends data to the specified host (unreliable sockets only).

Definition at line 115 of file udp_sock.cpp.

References _Bound, NLNET::CSock::_BytesSent, NLNET::CSock::_Sock, addr, nldebug, nlinfo, and NLNET::CSock::setLocalAddress.


Member Data Documentation

bool NLNET::CUdpSock::_Bound [private]
 

True after calling bind() or sendTo().

Definition at line 95 of file udp_sock.h.

Referenced by bind, and sendTo.


The documentation for this class was generated from the following files: