4 #ifndef GOSU_SOCKETS_HPP
5 #define GOSU_SOCKETS_HPP
39 const GOSU_UNIQUE_PTR<Impl> pimpl;
40 #if defined(GOSU_CPP11_ENABLED)
69 const void* buffer, std::size_t size);
94 const GOSU_UNIQUE_PTR<Impl> pimpl;
95 #if defined(GOSU_CPP11_ENABLED)
120 void send(
const void* buffer, std::size_t size);
124 std::tr1::function<void (const void*, std::size_t)>
onReceive;
133 const GOSU_UNIQUE_PTR<Impl> pimpl;
134 #if defined(GOSU_CPP11_ENABLED)
Wraps a TCP socket that is used for one part of bi-directional communication.
Includes all parts of C++03 (TR1) that are relevant for Gosu.
void setKeepAlive(bool value)
std::size_t maxMessageSize() const
Returns the maximum size, in bytes, of a packet that can be sent from this socket.
std::tr1::uint16_t SocketPort
Ports are returned from and given to Gosu functions in host byte order.
MessageSocket(SocketPort port)
Opens a message socket for listening at the specified port.
SocketAddress address() const
ListenerSocket(SocketPort port)
std::string addressToString(SocketAddress address)
Converts an address into a dotted IP4 string.
void update()
Collects all the packets that were sent to this socket and calls onReceive for each of them...
std::tr1::function< void()> onDisconnection
std::tr1::uint32_t SocketAddress
Addresses are returned from and given to Gosu functions in host byte order.
SocketPort port() const
Returns the local port of the socket.
const SocketPort anyPort
Constant that can be used as a placeholder for an arbitrary port, e.g.
std::tr1::function< void(SocketAddress, SocketPort, const void *, std::size_t)> onReceive
If assigned, will be called by update for every packet received.
SocketAddress remoteAddress() const
std::tr1::function< void(Socket &)> onConnection
This signal is fired by update() whenever someone connects to the port which is currently listened on...
std::size_t pendingBytes() const
void 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.
CommMode
Defines the way in which data is collected until the onReceive event is called for CommSockets...
Wraps a TCP socket that waits on a specific port and can create CommSocket instances via its onConnec...
SocketAddress address() const
Returns the local address of the socket.
SocketAddress address() const
CommSocket(CommMode mode, SocketAddress targetAddress, SocketPort targetPort)
SocketPort remotePort() const
SocketAddress stringToAddress(const std::string &s)
Tries to convert a dotted IP4 string into an address suitable for socket functions.
void send(const void *buffer, std::size_t size)
std::tr1::function< void(const void *, std::size_t)> onReceive