sfSocketUDP Class Reference

#include <SocketUDP.hpp>

List of all members.

Public Member Functions

 sfSocketUDP ()
bool Send (const char *Data, std::size_t Size, const sfIPAddress &Address, unsigned short Port)
bool Receive (char *Data, std::size_t MaxSize, std::size_t &SizeReceived, sfIPAddress &Address, unsigned short Port)
bool Send (sfPacket &Packet, const sfIPAddress &Address, unsigned short Port)
bool Receive (sfPacket &Packet, sfIPAddress &Address, unsigned short Port)
bool Close ()
bool operator== (const sfSocketUDP &Other) const
bool operator!= (const sfSocketUDP &Other) const
bool operator< (const sfSocketUDP &Other) const


Detailed Description

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

Definition at line 43 of file SocketUDP.hpp.


Constructor & Destructor Documentation

sfSocketUDP::sfSocketUDP (  ) 

Default constructor

Definition at line 37 of file SocketUDP.cpp.


Member Function Documentation

bool sfSocketUDP::Send ( const char *  Data,
std::size_t  Size,
const sfIPAddress 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 48 of file SocketUDP.cpp.

References sfIPAddress::ToString().

Referenced by Send().

bool sfSocketUDP::Receive ( char *  Data,
std::size_t  MaxSize,
std::size_t &  SizeReceived,
sfIPAddress 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 is it 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 93 of file SocketUDP.cpp.

References Close().

Referenced by Receive().

bool sfSocketUDP::Send ( sfPacket Packet,
const sfIPAddress Address,
unsigned short  Port 
)

Send a packet of data (must be bound to a port first)

Parameters:
Packet : 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 175 of file SocketUDP.cpp.

References sfPacket::GetData(), sfPacket::GetDataSize(), sfPacket::OnSend(), and Send().

bool sfSocketUDP::Receive ( sfPacket Packet,
sfIPAddress Address,
unsigned short  Port 
)

Receive a packet (must be bound to a port first) This function is blocking, ie. it won't return before a packet is received

Parameters:
Packet : 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 198 of file SocketUDP.cpp.

References sfPacket::Append(), sfPacket::Clear(), sfPacket::GetDataSize(), sfPacket::OnReceive(), and Receive().

bool sfSocketUDP::Close (  ) 

Close the socket

Returns:
True if operation has been successful

Definition at line 240 of file SocketUDP.cpp.

Referenced by Receive().

bool sfSocketUDP::operator== ( const sfSocketUDP Other  )  const

Comparison operator ==

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

Definition at line 255 of file SocketUDP.cpp.

References mySocket.

bool sfSocketUDP::operator!= ( const sfSocketUDP Other  )  const

Comparison operator !=

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

Definition at line 264 of file SocketUDP.cpp.

References mySocket.

bool sfSocketUDP::operator< ( const sfSocketUDP 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 275 of file SocketUDP.cpp.

References mySocket.


The documentation for this class was generated from the following files:
Generated for SFML by  doxygen 1.5.2