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
socket.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
16
/*
17
#ifndef __RAKNET_SOCKET_H
18
#define __RAKNET_SOCKET_H
19
20
#include "types.h"
21
#include "defines.h"
22
#include "Export.h"
23
#include "SocketIncludes.h"
24
#include "assert.h"
25
#include "SocketDefines.h"
26
#include "MTUSize.h"
27
28
namespace SLNet
29
{
30
31
struct RAK_DLL_EXPORT RakNetSocket
32
{
33
public:
34
RakNetSocket();
35
~RakNetSocket();
36
37
// void Accept(
38
// struct sockaddr *addr,
39
// int *addrlen);
40
41
inline int Connect(
42
const struct sockaddr *name,
43
int namelen) {return connect__(s,name,namelen);}
44
45
static RakNetSocket* Create
46
#ifdef __native_client__
47
(_PP_Instance_ _chromeInstance);
48
#else
49
(int af,
50
int type,
51
int protocol);
52
#endif
53
54
int Bind(
55
const struct sockaddr *addr,
56
int namelen);
57
58
inline int GetSockName(
59
struct sockaddr *name,
60
socklen_t * namelen) {return getsockname__(s,name,namelen);}
61
62
inline int GetSockOpt (
63
int level,
64
int optname,
65
char * optval,
66
socklen_t *optlen) {return getsockopt__(s,level,optname,optval,optlen);}
67
68
69
int IOCTLSocket(
70
long cmd,
71
unsigned long *argp);
72
73
int Listen (
74
int backlog);
75
76
inline int Recv(
77
char * buf,
78
int len,
79
int flags) {return recv__(s,buf,len,flags);}
80
81
inline int RecvFrom(
82
char * buf,
83
int len,
84
int flags,
85
struct sockaddr * from,
86
socklen_t * fromlen) {return recvfrom__(s,buf,len,flags,from,fromlen);}
87
88
// inline int Select(
89
// int nfds,
90
// fd_set *readfds,
91
// fd_set *writefds,
92
// fd_set *exceptfds,
93
// struct timeval *timeout) {return select__(nfds,readfds,writefds,exceptfds,timeout);}
94
95
inline int Send(
96
const char * buf,
97
int len,
98
int flags) {return send__(s,buf,len,flags);}
99
100
inline int SendTo(
101
const char * buf,
102
int len,
103
int flags,
104
const struct sockaddr *to,
105
int tolen) {return sendto__(s,buf,len,flags,to,tolen);}
106
107
#ifdef _WIN32
108
#elif defined(_PS3) || defined(__PS3__) || defined(SN_TARGET_PS3) || defined(_PS4) || defined(SN_TARGET_PSP2)
109
#else
110
inline int Fcntl(int cmd, int arg) {return fcntl(s,cmd,arg);}
111
#endif
112
113
114
#if defined(_WIN32) && !defined(WINDOWS_STORE_RT)
115
inline int _WSASendTo(
116
LPWSABUF lpBuffers,
117
DWORD dwBufferCount,
118
LPDWORD lpNumberOfBytesSent,
119
DWORD dwFlags,
120
const struct sockaddr FAR * lpTo,
121
int iTolen,
122
LPWSAOVERLAPPED lpOverlapped,
123
LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine
124
)
125
{ return WSASendTo(s,lpBuffers,dwBufferCount,lpNumberOfBytesSent,dwFlags,lpTo,iTolen,lpOverlapped,lpCompletionRoutine);}
126
127
#endif
128
129
int SetSockOpt(
130
int level,
131
int optname,
132
const char * optval,
133
int optlen);
134
135
int Shutdown(
136
int how);
137
138
139
inline void SetRemotePortRakNetWasStartedOn(unsigned short i) {remotePortRakNetWasStartedOn_PS3_PSP2=i;}
140
inline void SetUserConnectionSocketIndex(unsigned int i) {userConnectionSocketIndex=i;}
141
inline void SetBoundAddress(SystemAddress i) {boundAddress=i;}
142
inline void SetSocketFamily(unsigned short i) {socketFamily=i;}
143
inline void SetBlockingSocket(bool i) {blockingSocket=i;}
144
inline void SetExtraSocketOptions(unsigned int i) {extraSocketOptions=i;}
145
inline void SetChromeInstance(_PP_Instance_ i) {chromeInstance=i;}
146
inline void SetBoundAddressToLoopback(unsigned char ipVersion) {boundAddress.SetToLoopback(ipVersion);}
147
148
inline SystemAddress GetBoundAddress(void) const {return boundAddress;}
149
inline unsigned short GetRemotePortRakNetWasStartedOn(void) const {return remotePortRakNetWasStartedOn_PS3_PSP2;}
150
inline bool GetBlockingSocket(void) {return blockingSocket;}
151
inline unsigned int GetExtraSocketOptions(void) const {return extraSocketOptions;}
152
inline unsigned short GetSocketFamily(void) const {return socketFamily;}
153
inline _PP_Instance_ GetChromeInstance(void) const {return chromeInstance;}
154
inline unsigned int GetUserConnectionSocketIndex(void) const {
155
RakAssert(userConnectionSocketIndex!=(unsigned int)-1);
156
return userConnectionSocketIndex;}
157
158
159
#ifdef __native_client__
160
// Flag indicating if a SendTo is currently in progress
161
bool sendInProgress;
162
163
// Data for next queued packet to send, if nextSendSize > 0
164
char nextSendBuffer[MAXIMUM_MTU_SIZE];
165
166
// Size of next queued packet to send, or 0 if no queued packet
167
int nextSendSize;
168
169
// Destination address of queued packet
170
PP_NetAddress_Private nextSendAddr;
171
#endif
172
173
__UDPSOCKET__ s;
174
175
protected:
176
177
#if defined (_WIN32) && defined(USE_WAIT_FOR_MULTIPLE_EVENTS)
178
void* recvEvent;
179
#endif
180
181
#if defined(_PS3) || defined(__PS3__) || defined(SN_TARGET_PS3) || defined(_PS4) || defined(SN_TARGET_PSP2)
185
#endif
186
187
unsigned short remotePortRakNetWasStartedOn_PS3_PSP2;
188
unsigned int userConnectionSocketIndex;
189
SystemAddress boundAddress;
190
unsigned short socketFamily;
191
bool blockingSocket;
192
unsigned int extraSocketOptions;
193
_PP_Instance_ chromeInstance;
194
};
195
196
} // namespace SLNet
197
198
#endif
199
*/
Source
include
slikenet
socket.h
Generated on Wed Aug 14 2019 22:09:46 for SLikeNet by
1.8.2