socket.h

Go to the documentation of this file.
00001 
00002 //            Copyright (C) 2004-2007 by The Allacrost Project
00003 //                         All Rights Reserved
00004 //
00005 // This code is licensed under the GNU GPL version 2. It is free software 
00006 // and you may modify it and/or redistribute it under the terms of this license.
00007 // See http://www.gnu.org/copyleft/gpl.html for details.
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

Generated on Fri Jul 6 23:11:23 2007 for Hero of Allacrost by  doxygen 1.5.1