Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

Socket.h

Go to the documentation of this file.
00001 // Definition of the Socket class
00002 
00003 #ifndef Socket_class
00004 #define Socket_class
00005 
00006 
00007 #include <sys/types.h>
00008 #include <sys/socket.h>
00009 #include <netinet/in.h>
00010 #include <netdb.h>
00011 #include <unistd.h>
00012 #include <string>
00013 #include <arpa/inet.h>
00014 
00015 
00016 const int MAXHOSTNAME = 200;
00017 const int MAXCONNECTIONS = 5;
00018 const int MAXRECV = 500;
00019 
00020 class Socket
00021 {
00022  public:
00023   Socket();
00024   virtual ~Socket();
00025 
00026   // Server initialization
00027   bool create();
00028   bool bind ( const int port );
00029   bool listen() const;
00030   bool accept ( Socket& ) const;
00031 
00032   // Client initialization
00033   bool connect ( const std::string host, const int port );
00034 
00035   // Data Transimission
00036   bool send ( const std::string ) const;
00037   int recv ( std::string& ) const;
00038 
00039 
00040   void set_non_blocking ( const bool );
00041 
00042   bool is_valid() const { return m_sock != -1; }
00043 
00044  private:
00045 
00046   int m_sock;
00047   sockaddr_in m_addr;
00048 
00049 
00050 };
00051 
00052 
00053 #endif
00054 

Generated on Sun Apr 17 13:34:27 2005 for cavewriting by  doxygen 1.4.0