00001
00002
00003
00004
00005
00006
00007
00009
00018 #ifndef __SOCKET_HEADER__
00019 #define __SOCKET_HEADER__
00020
00021 #include "utils.h"
00022 #include "defs.h"
00023 #include <SDL/SDL.h>
00024 #ifdef __MACH__
00025 #include <SDL_net/SDL_net.h>
00026 #else
00027 #include <SDL/SDL_net.h>
00028 #endif
00029 #include <stdarg.h>
00030
00031 namespace hoa_socket
00032 {
00033
00041 class Socket
00042 {
00043 private:
00044 TCPsocket sock;
00045 SDLNet_SocketSet set;
00046 bool connected;
00047 public:
00052 Socket ();
00057 ~Socket ();
00058
00061 bool IsConnected ();
00062
00067 void Connect ( const std::string& host, uint16 port );
00070 void Disconnect ();
00071
00075 bool IsQueued ( uint32 wait_time = 0 );
00076
00082 uint32 SendBinary ( void* data, uint32 len );
00083
00089 uint32 RecvBinary ( void* location, uint32 maxlen );
00090
00095 void Write ( const char* format, ... );
00096
00100 std::string ReadLine ();
00101
00106 void ScanLine ( const char* format, ... );
00107 };
00108
00109 }
00110
00111 #endif