43 #include <sys/types.h>
44 #include <sys/socket.h>
45 #include <arpa/inet.h>
62 switch (addr->sa_family) {
64 inet_ntop (AF_INET, &(((
struct sockaddr_in *)addr)->sin_addr), ip,
sizeof (ip));
65 port = ntohs (((
struct sockaddr_in *)addr)->sin_port);
68 inet_ntop (AF_INET6, &(((
struct sockaddr_in6 *)addr)->sin6_addr), ip,
sizeof (ip));
69 port = ntohs (((
struct sockaddr_in6 *)addr)->sin6_port);
72 snprintf (ip,
sizeof (ip),
"UNKNOWN FAMILY: %d", addr->sa_family);
95 string send_str = str.substr( start, end ) ;
96 int bytes_written = write(
_socket, send_str.c_str(), send_str.length() ) ;
97 if( bytes_written == -1 )
99 string err(
"socket failure, writing on stream socket" ) ;
100 const char* error_info = strerror( errno ) ;
102 err +=
" " + (string)error_info ;
111 if( ( bytesRead = read(
_socket, inBuff, inSize ) ) < 1 )
113 string err(
"socket failure, reading on stream socket: " ) ;
114 const char *error_info = strerror( errno ) ;
116 err +=
" " + (string)error_info ;
145 << (
void *)
this <<
")" << endl ;
exception thrown if inernal error encountered
virtual void dump(ostream &strm) const
dumps information about this object
static ostream & LMarg(ostream &strm)
virtual void send(const string &str, int start, int end)
virtual int receive(char *inBuff, const int inSize)