Advertisement
Guest User

Socket.h

a guest
Feb 1st, 2011
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <windows.h>
  4. //#include <winsock2.h>
  5. #include <stdlib.h>
  6. #include <time.h>
  7.  
  8. #pragma comment(lib, "Ws2_32.lib")
  9.  
  10. class Socket {
  11.     protected:
  12.         WSADATA wsaData;
  13.         SOCKET mainSocket;
  14.         SOCKADDR_IN serverInfo;
  15.  
  16.     public:
  17.         Socket();
  18.         ~Socket();
  19.         void Start();
  20.         void Stop();
  21.         void HandleError( int , std::string );
  22.  
  23. };
  24.  
  25. class ServerSocket : public Socket {
  26.     protected:
  27.         SOCKET clientSocket;
  28.  
  29.         char * sendBuffer;
  30.         void   ManageSendBuffer();
  31.  
  32.     public:
  33.         void Initialize();
  34.         void Bind( int );
  35.         void Listen();
  36.         void AcceptClient();
  37.         void CloseClient();
  38.         void SendChar( const char * , int );
  39.         int  RecvChar( char * , int );
  40. };
  41.  
  42. class ClientSocket : public Socket {
  43.     public:
  44.         void Connect();
  45.         void SetServerInfo( std::string , int );
  46.  
  47.         void SendChar( const char * , int );
  48.         int  RecvChar( char * , int );
  49. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement