SLikeNet 0.1.3

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SocketLayer.h
Go to the documentation of this file.
1 /*
2 * Original work: Copyright (c) 2014, Oculus VR, Inc.
3 * All rights reserved.
4 *
5 * This source code is licensed under the BSD-style license found in the
6 * RakNet License.txt file in the licenses directory of this source tree. An additional grant
7 * of patent rights can be found in the RakNet Patents.txt file in the same directory.
8 *
9 *
10 * Modified work: Copyright (c) 2017, SLikeSoft UG (haftungsbeschränkt)
11 *
12 * This source code was modified by SLikeSoft. Modifications are licensed under the MIT-style
13 * license found in the license.txt file in the root directory of this source tree.
14 */
15
19
20
21
22
23 #ifndef __SOCKET_LAYER_H
24 #define __SOCKET_LAYER_H
25
26 #include "memoryoverride.h"
27 #include "types.h"
28 #include "smartptr.h"
29 //#include "socket.h"
30 #include "Export.h"
31 #include "MTUSize.h"
32 #include "string.h"
33
34 //#include "ClientContextStruct.h"
35
36 namespace SLNet
37 {
39 class RakPeer;
40
41 /*
42 class RAK_DLL_EXPORT SocketLayerOverride
43 {
44 public:
45 SocketLayerOverride() {}
46 virtual ~SocketLayerOverride() {}
47
49 virtual int RakNetSendTo( const char *data, int length, const SystemAddress &systemAddress )=0;
50
52 // Return -1 to use RakNet's normal recvfrom, 0 to abort RakNet's normal recvfrom, and positive to return data
53 virtual int RakNetRecvFrom( char dataOut[ MAXIMUM_MTU_SIZE ], SystemAddress *senderOut, bool calledFromMainThread )=0;
54 };
55 */
56
57 // A platform independent implementation of Berkeley sockets, with settings used by RakNet
58 class RAK_DLL_EXPORT SocketLayer
59 {
60
61 public:
62
64 SocketLayer();
65
66 // Destructor
67 ~SocketLayer();
68
69 /*
74 static RakNetSocket* CreateBoundSocket( RakPeer *peer, unsigned short port, bool blockingSocket, const char *forceHostAddress, unsigned int sleepOn10048, unsigned int extraSocketOptions, unsigned short socketFamily, _PP_Instance_ chromeInstance );
75 #if defined(WINDOWS_STORE_RT)
76 static RakNetSocket* CreateWindowsStore8Socket( RakPeer *peer, unsigned short port, bool blockingSocket, const char *forceHostAddress, unsigned int sleepOn10048, unsigned int extraSocketOptions, _PP_Instance_ chromeInstance );
77 #endif
78 static RakNetSocket* CreateBoundSocket_IPV4( RakPeer *peer, unsigned short port, bool blockingSocket, const char *forceHostAddress, unsigned int sleepOn10048, unsigned int extraSocketOptions, _PP_Instance_ chromeInstance );
79 #if RAKNET_SUPPORT_IPV6==1
80 static RakNetSocket* CreateBoundSocket_SupportIPV4And6( RakPeer *peer, unsigned short port, bool blockingSocket, const char *forceHostAddress, unsigned int sleepOn10048, unsigned int extraSocketOptions, unsigned short socketFamily, _PP_Instance_ chromeInstance );
81 #endif
82 static RakNetSocket* CreateBoundSocket_PS3Lobby( unsigned short port, bool blockingSocket, const char *forceHostAddress, unsigned short socketFamily );
83 static RakNetSocket* CreateBoundSocket_PSP2( unsigned short port, bool blockingSocket, const char *forceHostAddress, unsigned short socketFamily );
84 */
85
86 /*
87 #ifndef WINDOWS_STORE_RT
91 //static bool IsPortInUse_Old(unsigned short port, const char *hostAddress);
92 //static bool IsPortInUse(unsigned short port, const char *hostAddress, unsigned short socketFamily );
93 static bool IsSocketFamilySupported(const char *hostAddress, unsigned short socketFamily);
94 #endif
95 */
96
97 // static const char* DomainNameToIP_Old( const char *domainName );
98 // static const char* DomainNameToIP( const char *domainName );
99
104 // static void Write( RakNetSocket*writeSocket, const char* data, const int length );
105
112 // static void RecvFromBlocking_IPV4( RakNetSocket *s, RakPeer *rakPeer, char *dataOut, int *bytesReadOut, SystemAddress *systemAddressOut, SLNet::TimeUS *timeRead );
113 // #if RAKNET_SUPPORT_IPV6==1
114 // static void RecvFromBlockingIPV4And6( RakNetSocket *s, RakPeer *rakPeer, char *dataOut, int *bytesReadOut, SystemAddress *systemAddressOut, SLNet::TimeUS *timeRead );
115 // #endif
116 // static void RecvFromBlocking( RakNetSocket *s, RakPeer *rakPeer, char *dataOut, int *bytesReadOut, SystemAddress *systemAddressOut, SLNet::TimeUS *timeRead );
117 #if defined(WINDOWS_STORE_RT)
118 // static void RecvFromBlocking_WindowsStore8( RakNetSocket *s, RakPeer *rakPeer, char *dataOut, int *bytesReadOut, SystemAddress *systemAddressOut, SLNet::TimeUS *timeRead );
119 #endif
120
125 static SLNet::RakString GetSubNetForSocketAndIp(__UDPSOCKET__ inSock, SLNet::RakString inIpString);
126
127
130 // static void SetNonBlocking( RakNetSocket* listenSocket);
131
132
136 static void GetMyIP( SystemAddress addresses[MAXIMUM_NUMBER_OF_INTERNAL_IDS] );
137
138
146 // static int SendTo( UDPSOCKET s, const char *data, int length, const char ip[ 16 ], unsigned short port, unsigned short remotePortRakNetWasStartedOn_PS3, unsigned int extraSocketOptions, const char *file, const long line );
147
158 // static int SendToTTL( RakNetSocket *s, const char *data, int length, SystemAddress &systemAddress, int ttl );
159
167 // static int SendTo( RakNetSocket *s, const char *data, int length, SystemAddress systemAddress, const char *file, const long line );
168
169 // static unsigned short GetLocalPort(RakNetSocket *s);
170 static unsigned short GetLocalPort( __UDPSOCKET__ s);
171 // static void GetSystemAddress_Old ( RakNetSocket *s, SystemAddress *systemAddressOut );
172 static void GetSystemAddress_Old ( __UDPSOCKET__ s, SystemAddress *systemAddressOut );
173 // static void GetSystemAddress ( RakNetSocket *s, SystemAddress *systemAddressOut );
174 static void GetSystemAddress ( __UDPSOCKET__ s, SystemAddress *systemAddressOut );
175
176 // static void SetSocketLayerOverride(SocketLayerOverride *_slo);
177 // static SocketLayerOverride* GetSocketLayerOverride(void) {return slo;}
178
179 // static int SendTo_PS3Lobby( RakNetSocket *s, const char *data, int length, const SystemAddress &systemAddress );
180 // static int SendTo_PSP2( RakNetSocket *s, const char *data, int length, const SystemAddress &systemAddress );
181 // static int SendTo_360( RakNetSocket *s, const char *data, int length, const char *voiceData, int voiceLength, const SystemAddress &systemAddress );
182 // static int SendTo_PC( RakNetSocket *s, const char *data, int length, const SystemAddress &systemAddress, const char *file, const long line );
183 // #if defined(WINDOWS_STORE_RT)
184 // static int SendTo_WindowsStore8( RakNetSocket *s, const char *data, int length, const SystemAddress &systemAddress, const char *file, const long line );
185 // #endif
186 //
187 // static void SetDoNotFragment( RakNetSocket* listenSocket, int opt );
188 // static void SetSocketOptions( RakNetSocket* listenSocket, bool blockingSocket, bool setBroadcast);
189 static void SetSocketOptions( __UDPSOCKET__ listenSocket, bool blockingSocket, bool setBroadcast);
190
191
192 // AF_INET (default). For IPV6, use AF_INET6. To autoselect, use AF_UNSPEC.
193 static bool GetFirstBindableIP(char firstBindable[128], int ipProto);
194
195 private:
196
197 // static SocketLayerOverride *slo;
198 };
199
200 } // namespace SLNet
201
202 #endif