28#include <sys/socket.h>
66 virtual bool connect(
const char *
const Peer,
int PeerPort,
const char *
const Host = NULL,
int HostPort = 0);
92 virtual bool listen(
const char *
const Host,
int Port);
159 bool bindSocket(
const char *
const Host,
int Port);
175 bool bindInRange(
const char *
const Host,
int Low,
int High,
int Retries);
185 bool linger(
bool LingerOn,
int LingerTime = 0);
195 bool getPeer(std::string *Peer,
int *Port);
205 bool getHost(std::string *Host,
int *Port);
223 bool setPeer(
const char *
const Peer,
int Port);
224 bool setHost(
const char *
const Host,
int Port);
225 int recv(
void *buf,
int len,
int flags);
226 int send(
const void *
const buf,
int len,
int flags);
A simple thread-safe wrapper for select()
A class for dealing with sockets.
bool bindInRange(const char *const Host, int Low, int High, int Retries)
Tries repeated binds to a local address and port.
bool closeSocket(void)
Closes the connection.
bool linger(bool LingerOn, int LingerTime=0)
Sets the linger parameter of the socket.
bool setPeer(const char *const Peer, int Port)
void setWatch(IOWatch *watch)
Registers an IOWatch for this socket.
virtual bool listen(const char *const Host, int Port)
Starts listening.
bool getPeer(std::string *Peer, int *Port)
Retrieves peer information.
virtual bool reconnect()
Reopens the connection after closing it.
bool setHost(const char *const Host, int Port)
struct sockaddr m_HostAddr
TCPSocket()
Constructs a TCPSocket.
int getBufferStore(bufferStore &a, bool wait=true)
Receive data into a bufferStore .
bool sendBufferStore(const bufferStore &a)
Sends data from a bufferStore .
virtual bool createSocket(void)
Creates the socket.
bool getHost(std::string *Host, int *Port)
Retrieves local information.
virtual std::string toString()
Retrieve a string representation of the TCPSocket.
int send(const void *const buf, int len, int flags)
bool bindSocket(const char *const Host, int Port)
Binds to a local address and port.
TCPSocket * accept(std::string *Peer)
Accept a connection; blocking, non-cancellable.
struct sockaddr m_PeerAddr
int recv(void *buf, int len, int flags)
bool dataToGet(int sec, int usec) const
Check and optionally wait for incoming data.
virtual ~TCPSocket()
Destructor.
virtual bool connect(const char *const Peer, int PeerPort, const char *const Host=NULL, int HostPort=0)
Connects to a given host.
A generic container for an array of bytes.