Initial commit
[remote/remote-mci.git] / protocols / tcputil.h
blobaa141ea520ee6dadab1ce3e75f4a761088ba7480
1 #ifndef _TCPUTIL_H_
2 #define _TCPUTIL_H_
4 #include <netdb.h>
5 #include <unistd.h>
6 #include <arpa/inet.h>
7 #include <netinet/in.h>
8 #include <sys/socket.h>
9 #include <sys/time.h>
12 #include <string>
14 #include "types.h"
16 namespace remote { namespace protocols {
18 using namespace std;
20 int openServerSocket(struct sockaddr_in& server, unsigned int port, int max_pending, int retryInterval);
21 int openClientSocket(std::string address, unsigned int port);
22 int nextClient( int serversock, sockaddr_in& client );
24 void setSendTimeout(int fd, long seconds, long microseconds );
25 void setKeepAlive( int fd, int numProbes, int idleTime, int interval);
26 void setSendBuffer( int fd, int byteSize);
28 in_addr_t resolve(const char *ip_addr);
29 char* getHostByIp(in_addr ip);
31 template<class T> bool recv(int fd, T& value);
32 template<class T> bool send(int fd, T value);
34 template<class T> uint8_t* readvalue(T& value,uint8_t* buffer, uint32_t& buflen);
35 template<class T> uint8_t* writevalue(T value,uint8_t* buffer, uint32_t& buflen);
39 #endif