| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- /*
- * Copyright (c) 2014, Oculus VR, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- *
- */
- /*
- #ifndef __RAKNET_SOCKET_H
- #define __RAKNET_SOCKET_H
- #include "RakNetTypes.h"
- #include "RakNetDefines.h"
- #include "Export.h"
- #include "SocketIncludes.h"
- #include "RakAssert.h"
- #include "SocketDefines.h"
- #include "MTUSize.h"
- namespace RakNet
- {
- struct RAK_DLL_EXPORT RakNetSocket
- {
- public:
- RakNetSocket();
- ~RakNetSocket();
- // void Accept(
- // struct sockaddr *addr,
- // int *addrlen);
- inline int Connect(
- const struct sockaddr *name,
- int namelen) {return connect__(s,name,namelen);}
- static RakNetSocket* Create
- #ifdef __native_client__
- (_PP_Instance_ _chromeInstance);
- #else
- (int af,
- int type,
- int protocol);
- #endif
- int Bind(
- const struct sockaddr *addr,
- int namelen);
- inline int GetSockName(
- struct sockaddr *name,
- socklen_t * namelen) {return getsockname__(s,name,namelen);}
- inline int GetSockOpt (
- int level,
- int optname,
- char * optval,
- socklen_t *optlen) {return getsockopt__(s,level,optname,optval,optlen);}
- int IOCTLSocket(
- long cmd,
- unsigned long *argp);
- int Listen (
- int backlog);
- inline int Recv(
- char * buf,
- int len,
- int flags) {return recv__(s,buf,len,flags);}
- inline int RecvFrom(
- char * buf,
- int len,
- int flags,
- struct sockaddr * from,
- socklen_t * fromlen) {return recvfrom__(s,buf,len,flags,from,fromlen);}
- // inline int Select(
- // int nfds,
- // fd_set *readfds,
- // fd_set *writefds,
- // fd_set *exceptfds,
- // struct timeval *timeout) {return select__(nfds,readfds,writefds,exceptfds,timeout);}
- inline int Send(
- const char * buf,
- int len,
- int flags) {return send__(s,buf,len,flags);}
- inline int SendTo(
- const char * buf,
- int len,
- int flags,
- const struct sockaddr *to,
- int tolen) {return sendto__(s,buf,len,flags,to,tolen);}
- #ifdef _WIN32
- #elif defined(_PS3) || defined(__PS3__) || defined(SN_TARGET_PS3) || defined(_PS4) || defined(SN_TARGET_PSP2)
- #else
- inline int Fcntl(int cmd, int arg) {return fcntl(s,cmd,arg);}
- #endif
- #if defined(_WIN32) && !defined(WINDOWS_STORE_RT)
- inline int _WSASendTo(
- LPWSABUF lpBuffers,
- DWORD dwBufferCount,
- LPDWORD lpNumberOfBytesSent,
- DWORD dwFlags,
- const struct sockaddr FAR * lpTo,
- int iTolen,
- LPWSAOVERLAPPED lpOverlapped,
- LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine
- )
- { return WSASendTo(s,lpBuffers,dwBufferCount,lpNumberOfBytesSent,dwFlags,lpTo,iTolen,lpOverlapped,lpCompletionRoutine);}
- #endif
-
- int SetSockOpt(
- int level,
- int optname,
- const char * optval,
- int optlen);
- int Shutdown(
- int how);
- inline void SetRemotePortRakNetWasStartedOn(unsigned short i) {remotePortRakNetWasStartedOn_PS3_PSP2=i;}
- inline void SetUserConnectionSocketIndex(unsigned int i) {userConnectionSocketIndex=i;}
- inline void SetBoundAddress(SystemAddress i) {boundAddress=i;}
- inline void SetSocketFamily(unsigned short i) {socketFamily=i;}
- inline void SetBlockingSocket(bool i) {blockingSocket=i;}
- inline void SetExtraSocketOptions(unsigned int i) {extraSocketOptions=i;}
- inline void SetChromeInstance(_PP_Instance_ i) {chromeInstance=i;}
- inline void SetBoundAddressToLoopback(unsigned char ipVersion) {boundAddress.SetToLoopback(ipVersion);}
- inline SystemAddress GetBoundAddress(void) const {return boundAddress;}
- inline unsigned short GetRemotePortRakNetWasStartedOn(void) const {return remotePortRakNetWasStartedOn_PS3_PSP2;}
- inline bool GetBlockingSocket(void) {return blockingSocket;}
- inline unsigned int GetExtraSocketOptions(void) const {return extraSocketOptions;}
- inline unsigned short GetSocketFamily(void) const {return socketFamily;}
- inline _PP_Instance_ GetChromeInstance(void) const {return chromeInstance;}
- inline unsigned int GetUserConnectionSocketIndex(void) const {
- RakAssert(userConnectionSocketIndex!=(unsigned int)-1);
- return userConnectionSocketIndex;}
- #ifdef __native_client__
- // Flag indicating if a SendTo is currently in progress
- bool sendInProgress;
- // Data for next queued packet to send, if nextSendSize > 0
- char nextSendBuffer[MAXIMUM_MTU_SIZE];
- // Size of next queued packet to send, or 0 if no queued packet
- int nextSendSize;
- // Destination address of queued packet
- PP_NetAddress_Private nextSendAddr;
- #endif
- __UDPSOCKET__ s;
- protected:
- #if defined (_WIN32) && defined(USE_WAIT_FOR_MULTIPLE_EVENTS)
- void* recvEvent;
- #endif
- #if defined(_PS3) || defined(__PS3__) || defined(SN_TARGET_PS3) || defined(_PS4) || defined(SN_TARGET_PSP2)
- /// PS3: Set for the PS3, when using signaling.
- /// PS3: Connect with the port returned by signaling. Set this to whatever port RakNet was actually started on
- /// PSP2: Set non-zero to use SCE_NET_SOCK_DGRAM_P2P. This should be done for ad-hoc or with
- #endif
- unsigned short remotePortRakNetWasStartedOn_PS3_PSP2;
- unsigned int userConnectionSocketIndex;
- SystemAddress boundAddress;
- unsigned short socketFamily;
- bool blockingSocket;
- unsigned int extraSocketOptions;
- _PP_Instance_ chromeInstance;
- };
- } // namespace RakNet
- #endif
- */
|