sf::SocketUDP Class Reference

SocketUDP wraps a socket using UDP protocol to send data fastly (but with less safety). More...

#include <SocketUDP.hpp>

List of all members.


Public Member Functions

 SocketUDP ()
 Default constructor.
bool Send (const char *Data, std::size_t Size, const IPAddress &Address, unsigned short Port)
 Send an array of bytes.
bool Receive (char *Data, std::size_t MaxSize, std::size_t &SizeReceived, IPAddress &Address, unsigned short Port)
 Receive an array of bytes.
bool Send (Packet &PacketToSend, const IPAddress &Address, unsigned short Port)
 Send a packet of data.
bool Receive (Packet &PacketToReceive, IPAddress &Address, unsigned short Port)
 Receive a packet.
bool Close ()
 Close the socket.
bool operator== (const SocketUDP &Other) const
 Comparison operator ==.
bool operator!= (const SocketUDP &Other) const
 Comparison operator !=.
bool operator< (const SocketUDP &Other) const
 Comparison operator <.

Friends

class Selector< SocketUDP >

Detailed Description

SocketUDP wraps a socket using UDP protocol to send data fastly (but with less safety).

Definition at line 45 of file SocketUDP.hpp.


Constructor & Destructor Documentation

sf::SocketUDP::SocketUDP (  ) 

Default constructor.

Definition at line 39 of file SocketUDP.cpp.


Member Function Documentation

bool sf::SocketUDP::Send ( const char *  Data,
std::size_t  Size,
const IPAddress Address,
unsigned short  Port 
)

Send an array of bytes.

Parameters:
Data : Pointer to the bytes to send
Size : Number of bytes to send
Address : Address of the computer to send the packet to
Port : Port to use for communication
Returns:
True if operation has been successful

Definition at line 50 of file SocketUDP.cpp.

bool sf::SocketUDP::Receive ( char *  Data,
std::size_t  MaxSize,
std::size_t &  SizeReceived,
IPAddress Address,
unsigned short  Port 
)

Receive an array of bytes.

This function is blocking, ie. it won't return before some bytes have been received

Parameters:
Data : Pointer to a byte array to fill (make sure it is big enough)
MaxSize : Maximum number of bytes to read
SizeReceived : Number of bytes received
Address : Address of the computer to send the packet to
Port : Port to use for communication
Returns:
True if operation has been successful

Definition at line 95 of file SocketUDP.cpp.

bool sf::SocketUDP::Send ( Packet PacketToSend,
const IPAddress Address,
unsigned short  Port 
)

Send a packet of data.

Parameters:
PacketToSend : Packet to send
Address : Address of the computer to send the packet to
Port : Port to use for communication
Returns:
True if operation has been successful

Definition at line 176 of file SocketUDP.cpp.

bool sf::SocketUDP::Receive ( Packet PacketToReceive,
IPAddress Address,
unsigned short  Port 
)

Receive a packet.

This function is blocking, ie. it won't return before a packet is received

Parameters:
PacketToReceive : Packet to fill with received data
Address : Address of the computer that sent the packet
Port : Port to use for communication
Returns:
True if operation has been successful

Definition at line 199 of file SocketUDP.cpp.

bool sf::SocketUDP::Close (  ) 

Close the socket.

Returns:
True if operation has been successful

Definition at line 241 of file SocketUDP.cpp.

bool sf::SocketUDP::operator== ( const SocketUDP Other  )  const

Comparison operator ==.

Parameters:
Other : Socket to compare
Returns:
True if *this == Other

Definition at line 256 of file SocketUDP.cpp.

bool sf::SocketUDP::operator!= ( const SocketUDP Other  )  const

Comparison operator !=.

Parameters:
Other : Socket to compare
Returns:
True if *this != Other

Definition at line 265 of file SocketUDP.cpp.

bool sf::SocketUDP::operator< ( const SocketUDP Other  )  const

Comparison operator <.

Provided for compatibility with standard containers, as comparing two sockets doesn't make much sense...

Parameters:
Other : Socket to compare
Returns:
True if *this < Other

Definition at line 276 of file SocketUDP.cpp.


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