12 #include <sys/types.h>
13 #include <sys/socket.h>
14 #include <netinet/in.h>
17 #include <arpa/inet.h>
46 int sendall(
const char* buffer,
size_t bufferLength );
60 return addr_.sin_port;
75 void bind( const
int port ) throw( SocketException& );
76 void listen() const throw( SocketException& );
77 void accept(
Socket& newSocket ) throw( SocketException& );
80 void accept(
Socket& newSocket,
int timeoutMillis ) throw( SocketException& );
83 void connect( const
char* host, const
int port ) throw( SocketException& );
88 void connect( const
char* host, const
int port,
int timeoutMillis ) throw( SocketException& );
90 void setNonBlocking( const
bool nonBlocking ) throw( SocketException& );
97 void setTimeval(
const int milliseconds,
struct timeval& tv );
A wrapper around sys/socket.h for tcp communications between Socket instances – use daughter classes...
Definition: Socket.h:33
Definition: SocketException.h:6
sockaddr_in addr_
Definition: Socket.h:102
const int MAXCONNECTIONS
Definition: Socket.h:22
void create()
Definition: Socket.cpp:32
int close()
Definition: Socket.cpp:273
bool isValid() const
Definition: Socket.h:92
bool connected_
Definition: Socket.h:103
void bind(const int port)
Definition: Socket.cpp:51
const int MAXHOSTNAME
Definition: Socket.h:21
int sendall(const char *buffer, size_t bufferLength)
Like send but making sure the whole requested buffer is sent out.
Definition: Socket.cpp:166
int sock_
Definition: Socket.h:101
virtual ~Socket()
Definition: Socket.cpp:24
int getPort()
Definition: Socket.h:58
void listen() const
Definition: Socket.cpp:67
void accept(Socket &newSocket)
Definition: Socket.cpp:79
void setNonBlocking(const bool nonBlocking)
Definition: Socket.cpp:458
const int MAXRECV
Definition: Socket.h:23
Socket()
Definition: Socket.cpp:17
const int SIMPORT
Definition: Socket.h:24
int setTimeout(const int milliseconds)
Definition: Socket.cpp:259
int send(const char *buffer, size_t bufferLength) const
If return value is -1, check errno.
Definition: Socket.cpp:148
void connect(const char *host, const int port)
Definition: Socket.cpp:286
void setTimeval(const int milliseconds, struct timeval &tv)
Definition: Socket.cpp:267
int recv(char *buffer, size_t bufferLength) const
Blocking read.
Definition: Socket.cpp:196
int getDescriptor()
exposes the socket descriptor to facilitate direct operations
Definition: Socket.h:64