zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Zeni::UDP_Socket Class Reference

A UDP Socket for sending and receiving data. More...

#include <Net.h>

Inherited by Zeni::Split_UDP_Socket.

Public Member Functions

 UDP_Socket (const Uint16 &port)
 
virtual ~UDP_Socket ()
 
IPaddress peer_address () const
 Apparently only works if the port was explicitly specified. More...
 
virtual int receive (IPaddress &ip, const void *const &data, const Uint16 &num_bytes)
 Receive data of up to data.size() from the returned IPaddress; Will error if num_bytes/data.size() is too low. More...
 
virtual int receive (IPaddress &ip, String &data)
 
virtual void send (const IPaddress &ip, const void *const &data, const Uint16 &num_bytes)
 Send data to an IPaddress. More...
 
virtual void send (const IPaddress &ip, const String &data)
 

Detailed Description

A UDP Socket for sending and receiving data.

UDP Sockets are little more than a lock on a given port on a computer. A program that might need a dozen TCP Sockets can get by with one UDP_Socket. Note that if you opt to use UDP_Sockets, you'll get faster data transmission at the expense of reliability. If all the data being transmitted has to get there, you're better off using TCP_Sockets, even if the order of arrival is unimportant. Code carefully.

Author
bazald

Contact: bazal.nosp@m.d@ze.nosp@m.nipex.nosp@m..com

Definition at line 237 of file Net.h.

Constructor & Destructor Documentation

Zeni::UDP_Socket::UDP_Socket ( const Uint16 port)
Zeni::UDP_Socket::~UDP_Socket ( )
virtual

Definition at line 294 of file Net.cpp.

References Zeni::Singleton< Net >::remove_pre_uninit(), and SDLNet_UDP_Close().

Member Function Documentation

IPaddress Zeni::UDP_Socket::peer_address ( ) const

Apparently only works if the port was explicitly specified.

Definition at line 301 of file Net.cpp.

References SDLNet_UDP_GetPeerAddress().

int Zeni::UDP_Socket::receive ( IPaddress ip,
const void *const data,
const Uint16 num_bytes 
)
virtual

Receive data of up to data.size() from the returned IPaddress; Will error if num_bytes/data.size() is too low.

Reimplemented in Zeni::Split_UDP_Socket.

Definition at line 330 of file Net.cpp.

References UDPpacket::address, IPaddress::host, UDPpacket::len, IPaddress::port, and SDLNet_UDP_Recv().

Referenced by receive(), and Zeni::Split_UDP_Socket::receive().

int Zeni::UDP_Socket::receive ( IPaddress ip,
String data 
)
virtual

Reimplemented in Zeni::Split_UDP_Socket.

Definition at line 356 of file Net.cpp.

References Zeni::String::c_str(), receive(), Zeni::String::resize(), and Zeni::String::size().

void Zeni::UDP_Socket::send ( const IPaddress ip,
const void *const data,
const Uint16 num_bytes 
)
virtual

Send data to an IPaddress.

Reimplemented in Zeni::Split_UDP_Socket.

Definition at line 305 of file Net.cpp.

References SDLNet_UDP_Send(), and u.

Referenced by send(), and Zeni::Split_UDP_Socket::send().

void Zeni::UDP_Socket::send ( const IPaddress ip,
const String data 
)
virtual

Reimplemented in Zeni::Split_UDP_Socket.

Definition at line 326 of file Net.cpp.

References Zeni::String::c_str(), send(), and Zeni::String::size().


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