gwnavruntime/visualdebug/amp/Amp_Socket.h Source File
Go to the documentation of this file.
17 #ifndef INC_KY_AMP_SOCKET_H
18 #define INC_KY_AMP_SOCKET_H
24 #ifdef KY_ENABLE_SOCKETS
35 virtual ~SocketInterface() { }
36 virtual bool CreateStream(
bool listener) = 0;
37 virtual bool CreateDatagram(
bool broadcast) = 0;
38 virtual bool Bind() = 0;
39 virtual bool Listen(
int) = 0;
40 virtual bool Connect() = 0;
41 virtual bool Accept(
int timeoutMs) = 0;
42 virtual int Send(
const char*, UPInt)
const = 0;
43 virtual int Receive(
char*,
int)
const = 0;
44 virtual int SendBroadcast(
const char*, UPInt)
const = 0;
45 virtual int ReceiveBroadcast(
char*,
int)
const = 0;
46 virtual void SetListenPort(UInt32) = 0;
47 virtual void SetBroadcastPort(UInt32) = 0;
48 virtual void SetAddress(UInt32,
const char*) = 0;
49 virtual void SetBlocking(
bool) = 0;
50 virtual void SetBroadcast(
bool) = 0;
51 virtual void GetName(UInt32*, UInt32*,
char*, UInt32) = 0;
52 virtual bool Shutdown(
int timeoutMsForOrderlyRelease) = 0;
53 virtual bool Startup() = 0;
54 virtual void Cleanup() = 0;
55 virtual int GetLastError()
const = 0;
56 virtual bool IsValid()
const = 0;
57 virtual bool IsListening()
const = 0;
58 virtual bool ShutdownListener(
int timeoutMsForOrderlyRelease) = 0;
59 virtual bool CheckAbort()
const = 0;
62 class SocketImplFactory
65 virtual ~SocketImplFactory() { }
66 virtual SocketInterface* Create() = 0;
67 virtual void Destroy(SocketInterface* socketImpl) = 0;
71 class DefaultSocketFactory :
public NewOverrideBase<Stat_Default_Mem>,
public SocketImplFactory
74 virtual ~DefaultSocketFactory() { }
75 virtual SocketInterface* Create()
79 virtual void Destroy(SocketInterface* socketImpl)
94 Socket(
bool initLib, SocketImplFactory* socketImplFactory);
98 bool CreateClient(
const char* ipAddress, UInt32 port, String* errorMsg);
99 bool CreateServer(UInt32 port, String* errorMsg);
101 void Destroy(
int timeoutMsForOrderlyRelease = 0);
103 bool Accept(
int timeoutMs);
105 int Send(
const char* dataBuffer, UPInt dataBufferSize, LogSilentMode silentMode = LOG_VERBOSE)
const;
107 int Receive(
char* dataBuffer,
int dataSize, LogSilentMode silentMode = LOG_VERBOSE)
const;
109 bool IsConnected()
const;
111 void SetBlocking(
bool blocking);
113 void SetLock(Lock* lock);
115 bool IsValid()
const;
117 bool CheckAbort()
const;
120 enum { SocketListenBacklog = 10 };
122 SocketImplFactory* SocketFactory;
123 SocketInterface* SocketImpl;
127 #ifdef KY_ENABLE_THREADS
132 bool Shutdown(
int timeoutMsForOrderlyRelease);
137 class BroadcastSocket
140 BroadcastSocket(
bool initLib, SocketImplFactory* socketImplFactory);
142 bool Create(UInt32 port,
bool broadcast);
144 int Broadcast(
const char* dataBuffer, UPInt dataBufferSize)
const;
145 int Receive(
char* dataBuffer,
int dataSize)
const;
146 void GetName(UInt32* port, UInt32* address,
char* name, UInt32 nameSize)
const;
147 int GetLastError()
const {
return SocketImpl->GetLastError(); }
150 SocketImplFactory* SocketFactory;
151 SocketInterface* SocketImpl;
156 #ifndef KY_AMP_CHANNEL_NAME
157 #define KY_AMP_CHANNEL_NAME "GwNavAmp"
164 #endif // KY_ENABLE_SOCKETS
166 #endif // INC_KY_AMP_SOCKET_H
Definition: gamekitcrowddispersion.h:20