|
duncan
Mom and Dad were wrong!
|
#include <connection.h>

Public Member Functions | |
| Connection (const std::string &address, PacketListener *lis=0, port_t port=kPort) | |
| Connection (port_t port=kPort) | |
| ~Connection () | |
| void | send (const void *buf, size_t size, index_t peer=0, bool reliable=kReliable) |
| void | set_listener (PacketListener *) |
| bool | connected () |
| void | receive () |
| unsigned int | bytes_sent () |
| unsigned int | bytes_received () |
Handles a network connection.
This class provides an abstract interface to a connection made over network sockets. The connection is opened during object construction, and closed in destruction.
see LICENSE
| Connection::Connection | ( | const std::string & | address, |
| PacketListener * | lis = 0, |
||
| port_t | port = kPort |
||
| ) |
Client-like constructor. Creates a Connection and connects to the specified server.
| address | hostname or ip to which to connect |
| lis | pointer to listener object |
| port | port on which to connect |
| std::runtime_error | if ENet fails |
| std::runtime_error | if ENet cannot resolve the address |
| std::runtime_error | if ENet cannot connect to the server, or connect times out |
Server-like constructor. Creates a Connection to listen locally.
| port | port on which to listen |
| std::runtime_error | if ENet fails |
| Connection::~Connection | ( | ) |
Disconnects all peers.
| unsigned int Connection::bytes_received | ( | ) |
Get the number of bytes received by the host since the last call to this function.
| unsigned int Connection::bytes_sent | ( | ) |
Get the number of bytes sent from the host since the last call to this function.
| void Connection::receive | ( | ) |
Processes any events sent to this Connection. Connect, disconnect and receive events are forwarded to the listener.
| void Connection::send | ( | const void * | buf, |
| size_t | size, | ||
| index_t | peer = 0, |
||
| bool | reliable = kReliable |
||
| ) |
Send some data to a peer.
| buf | buffer of data |
| size | length of buffer |
| peer | index of peer to whom to send data |
1.7.4