1 #ifndef REMOTE_PROTOCOLS__TCPUTIL_H
2 #define REMOTE_PROTOCOLS_TCPUTIL_H
8 #include <netinet/in.h>
9 #include <sys/socket.h>
15 #include "libutil/Log.h"
16 #include "MMSException.h"
18 namespace remote
{ namespace protocols
{
21 using namespace remote::util
;
23 int openServerSocket(struct sockaddr_in
& server
, unsigned int port
, int max_pending
, int retryInterval
);
24 int openClientSocket(std::string address
, unsigned int port
);
25 int nextClient( int serversock
, sockaddr_in
& client
);
27 void setSendTimeout(int fd
, long seconds
, long microseconds
);
28 void setKeepAlive( int fd
, int numProbes
, int idleTime
, int interval
);
29 void setSendBuffer( int fd
, int byteSize
);
31 in_addr_t
resolve(const char *ip_addr
);
32 const char *getHostByIp(in_addr ip
);
34 template<class T
> bool recv(int fd
, T
& value
);
35 template<class T
> bool send(int fd
, T value
);
37 template<class T
> uint8_t* readvalue(T
& value
,uint8_t* buffer
, uint32_t& buflen
);
38 template<class T
> uint8_t* writevalue(T value
,uint8_t* buffer
, uint32_t& buflen
);