#include <SocketUDP.hpp>
Public Member Functions | |
| SocketUDP () | |
| Default constructor. | |
| void | SetBlocking (bool Blocking) |
| Change the blocking state of the socket. | |
| bool | Bind (unsigned short Port) |
| Bind the socket to a specific port. | |
| bool | Unbind () |
| Unbind the socket from its previous port, if any. | |
| Socket::Status | Send (const char *Data, std::size_t Size, const IPAddress &Address, unsigned short Port) |
| Send an array of bytes. | |
| Socket::Status | Receive (char *Data, std::size_t MaxSize, std::size_t &SizeReceived, IPAddress &Address) |
| Receive an array of bytes. | |
| Socket::Status | Send (Packet &PacketToSend, const IPAddress &Address, unsigned short Port) |
| Send a packet of data. | |
| Socket::Status | Receive (Packet &PacketToReceive, IPAddress &Address) |
| Receive a packet. | |
| bool | Close () |
| Close the socket. | |
| bool | IsValid () const |
| Check if the socket is in a valid state ; this function can be called any time to check if the socket is OK. | |
| unsigned short | GetPort () const |
| Get the port the socket is currently bound to. | |
| 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 > |
Definition at line 45 of file SocketUDP.hpp.
| sf::SocketUDP::SocketUDP | ( | ) |
Default constructor.
| void sf::SocketUDP::SetBlocking | ( | bool | Blocking | ) |
Change the blocking state of the socket.
The default behaviour of a socket is blocking
| Blocking | : Pass true to set the socket as blocking, or false for non-blocking |
| bool sf::SocketUDP::Bind | ( | unsigned short | Port | ) |
Bind the socket to a specific port.
| Port | : Port to bind the socket to |
| bool sf::SocketUDP::Unbind | ( | ) |
Unbind the socket from its previous port, if any.
| Socket::Status sf::SocketUDP::Send | ( | const char * | Data, | |
| std::size_t | Size, | |||
| const IPAddress & | Address, | |||
| unsigned short | Port | |||
| ) |
Send an array of bytes.
| 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 send the data to |
| Socket::Status sf::SocketUDP::Receive | ( | char * | Data, | |
| std::size_t | MaxSize, | |||
| std::size_t & | SizeReceived, | |||
| IPAddress & | Address | |||
| ) |
Receive an array of bytes.
This function will block if the socket is blocking
| 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 which sent the data |
| Socket::Status sf::SocketUDP::Send | ( | Packet & | PacketToSend, | |
| const IPAddress & | Address, | |||
| unsigned short | Port | |||
| ) |
Send a packet of data.
| PacketToSend | : Packet to send | |
| Address | : Address of the computer to send the packet to | |
| Port | : Port to send the data to |
| Socket::Status sf::SocketUDP::Receive | ( | Packet & | PacketToReceive, | |
| IPAddress & | Address | |||
| ) |
Receive a packet.
This function will block if the socket is blocking
| PacketToReceive | : Packet to fill with received data | |
| Address | : Address of the computer which sent the packet |
| bool sf::SocketUDP::Close | ( | ) |
Close the socket.
| bool sf::SocketUDP::IsValid | ( | ) | const |
Check if the socket is in a valid state ; this function can be called any time to check if the socket is OK.
| unsigned short sf::SocketUDP::GetPort | ( | ) | const |
Get the port the socket is currently bound to.
| bool sf::SocketUDP::operator== | ( | const SocketUDP & | Other | ) | const |
| bool sf::SocketUDP::operator!= | ( | const SocketUDP & | Other | ) | const |
| 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...
| Other | : Socket to compare |