Protocols: Make the inclusion guard uniform and unique
[remote/remote-mci.git] / protocols / tcputil.h
blob0a74ea779f640ea48ab8f18b86e096071bec15ce
1 #ifndef REMOTE_PROTOCOLS__TCPUTIL_H
2 #define REMOTE_PROTOCOLS_TCPUTIL_H
4 #include <errno.h>
5 #include <netdb.h>
6 #include <unistd.h>
7 #include <arpa/inet.h>
8 #include <netinet/in.h>
9 #include <sys/socket.h>
10 #include <sys/time.h>
12 #include <string>
14 #include "types.h"
15 #include "libutil/Log.h"
16 #include "MMSException.h"
18 namespace remote { namespace protocols {
20 using namespace std;
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);
42 #endif