#ifndef _TCP_SERVER_H
#define _TCP_SERVER_H
/*

tcp_server class.

Author: Matthew William Coan
Date: Tue Jul 27 15:44:40 EDT 2010

*/

//#define OS_UNIX
//#define OS_WINDOWS

#ifdef OS_UNIX
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#define closesocket(a) close(a)
#define SOCKET int
#endif 

#ifdef OS_WINDOWS
#include <winsock2.h>
#include <stdio.h>
#include <assert.h>
#endif


#include <cstring>

namespace net_tools {

class tcp_server {
   const char * _ip_address;
   const int _port;
   sockaddr_in _svr, _cli;
   SOCKET _fd, _client_fd;

public:
   tcp_server(const char * ip_address, 
              const int port);
   ~tcp_server();

   int accept();
   void close();
};

}

#endif /* _TCP_SERVER_H */

