Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | Related Pages

socket.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                socket.h  -  Virtual base class for network sockets
00003                              -------------------
00004     begin                : Thu Oct 10 2002
00005     copyright            : (C) 2002 by Reality Rift Studios
00006     email                : mattias@realityrift.com
00007  ***************************************************************************
00008 
00009  The contents of this file are subject to the Mozilla Public License Version
00010  1.1 (the "License"); you may not use this file except in compliance with
00011  the License. You may obtain a copy of the License at 
00012  http://www.mozilla.org/MPL/
00013 
00014  Software distributed under the License is distributed on an "AS IS" basis,
00015  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00016  for the specific language governing rights and limitations under the
00017  License.
00018 
00019  The Original Code is the NeoEngine, socket.h
00020 
00021  The Initial Developer of the Original Code is Mattias Jansson.
00022  Portions created by Mattias Jansson are Copyright (C) 2002
00023  Reality Rift Studios. All Rights Reserved.
00024 
00025  ***************************************************************************/
00026 
00027 
00028 #ifndef __NESOCKET_H
00029 #define __NESOCKET_H
00030 
00031 
00038 #include <string>
00039 #include "base.h"
00040 
00041 namespace NeoEngine
00042 {
00043 
00044 
00045 //Forward declarations
00046 class SocketCallback;
00047 
00048 
00049 
00050 
00056 class NEOENGINE_API Socket
00057 {
00058     public:
00059 
00064         enum SOCKETEVENT
00065         {
00067           NONE           = 0x0000000,
00068 
00070           CONNECTION     = 0x0000001,
00071 
00073           DATAIN         = 0x0000002,
00074 
00076           ERR            = 0x0000004,
00077 
00079           HUP            = 0x0000008,
00080 
00082           NVAL           = 0x0000010,
00083 
00085           TIMEOUT        = 0x0000020,
00086 
00088           CONNECTED      = 0x0000040,
00089 
00090           INVALID        = 0xFFFFFFF    //Invalid event, error in syscall or invalid arguments
00091         };
00092 
00093 
00094     public:
00095 
00097         SocketCallback                      *m_pkCallback;
00098 
00099 
00100 
00104                                                Socket( SocketCallback *pkCallback = 0 ) : m_pkCallback( pkCallback ) {}
00105 
00108         virtual                               ~Socket() {}
00109 
00113         virtual int                            GetFD() = 0;
00114 
00119         virtual void                           SetBlocking( bool bBlock = false ) = 0;
00120 
00126         virtual unsigned int                   Poll( int iTimeout ) = 0;
00127 };
00128 
00129 
00130 
00131 
00137 class NEOENGINE_API SocketCallback
00138 {
00139     public:
00140 
00147         virtual void                           SocketEventCallback( class Socket *pkSocket, Socket::SOCKETEVENT eEvent, void *pData ) = 0;
00148 };
00149 
00150 
00151 }; // namespace NeoEngine
00152 
00153 
00154 
00155 
00156 
00157 #endif

Generated on Wed Jan 21 14:21:07 2004 for NeoEngine by doxygen 1.3.5