/* this is version 2.0 of socket.h */

#ifndef SOCKET_H
#define SOCKET_H

#define SOCKMAXSOCKETNAMELEN 255
#define SOCKMAXLINELENGTH 255

extern "C"
{
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
}
#include <iostream>
#include <string>
//include "gvar.h"

class tSocket{
 private:
   std::string sHostName;
   int iPort;
   int iConnected;
   int iSockHandle;
   sockaddr_in aHostAddr;
 public:
   tSocket(std::string aInHost, int aPort);
   ~tSocket();
   void closeConnection();
   int createSocket();
   int connectSocket();   // may block! called by the connect thread only...in Future
   int isConnected();   	// returns that the connection is still alive (use it before readline)
   char readChar();
   void writeLine(char* astr);

//   int tryConnect();
//   char* readLine();
};

#endif //SOCKET_H

