Gosu::MessageSocket Class Reference

Wraps an UDP socket. More...

List of all members.

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 )


Detailed Description

Wraps an UDP socket.

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.


Constructor & Destructor Documentation

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.


Member Function Documentation

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.


Member Data Documentation

boost::function<void (SocketAddress, SocketPort, const void*, std::size_t) Gosu::MessageSocket::onReceive)

If assigned, will be called by update for every packet received.


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

Generated on Sat Dec 6 03:53:17 2008 for Gosu by  doxygen 1.5.5