Public Member Functions | |
MessageSocket (SocketPort port) | |
SocketAddress | address () const |
SocketPort | port () const |
std::size_t | maxMessageSize () const |
void | update () |
void | send (SocketAddress address, SocketPort port, const void *buffer, std::size_t size) |
Public Attributes | |
boost::function< void(SocketAddress, SocketPort, const void *, std::size_t) | onReceive ) |
Message sockets can send data to and receive data from arbitrary addresses. Also, message sockets send messages (packets) which are limited in size and can arrive in any order, or not at all.
Gosu::MessageSocket::MessageSocket | ( | SocketPort | port | ) | [explicit] |
Opens a message socket for listening at the specified port.
Gosu::anyPort may be passed to have the message socket use a random free port.
SocketAddress Gosu::MessageSocket::address | ( | ) | const |
Returns the local address of the socket.
SocketPort Gosu::MessageSocket::port | ( | ) | const |
Returns the local port of the socket.
std::size_t Gosu::MessageSocket::maxMessageSize | ( | ) | const |
Returns the maximum size, in bytes, of a packet that can be sent from this socket.
void Gosu::MessageSocket::update | ( | ) |
Collects all the packets that were sent to this socket and calls onReceive for each of them.
void Gosu::MessageSocket::send | ( | SocketAddress | address, | |
SocketPort | port, | |||
const void * | buffer, | |||
std::size_t | size | |||
) |
Sends something to the given port of the computer identified by the address.
boost::function<void (SocketAddress, SocketPort, const void*, std::size_t) Gosu::MessageSocket::onReceive) |
If assigned, will be called by update for every packet received.