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
RakNetSocket2_Windows_Linux_360.cpp
Go to the documentation of this file.
1 /*
2 * 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 #include "slikenet/EmptyHeader.h"
17
18 #ifdef RAKNET_SOCKET_2_INLINE_FUNCTIONS
19
20 #ifndef RAKNETSOCKET2_WINDOWS_LINUX_360_CPP
21 #define RAKNETSOCKET2_WINDOWS_LINUX_360_CPP
22
23 #if (defined(_WIN32) || defined(__GNUC__) || defined(__GCCXML__) || defined(__S3E__) ) && !defined(WINDOWS_STORE_RT) && !defined(__native_client__)
24
25 RNS2SendResult RNS2_Windows_Linux_360::Send_Windows_Linux_360NoVDP( RNS2Socket rns2Socket, RNS2_SendParameters *sendParameters, const char *file, unsigned int line ) {
26
27 int len=0;
28 do
29 {
30 (void) file;
31 (void) line;
32
33
34 int oldTTL=-1;
35 if (sendParameters->ttl>0)
36 {
37 socklen_t opLen=sizeof(oldTTL);
38 // Get the current TTL
39 if (getsockopt__(rns2Socket, sendParameters->systemAddress.GetIPPROTO(), IP_TTL, ( char * ) & oldTTL, &opLen ) != -1)
40 {
41 int newTTL=sendParameters->ttl;
42 setsockopt__(rns2Socket, sendParameters->systemAddress.GetIPPROTO(), IP_TTL, ( char * ) & newTTL, sizeof ( newTTL ) );
43 }
44 }
45
46
47 if (sendParameters->systemAddress.address.addr4.sin_family==AF_INET)
48 {
49 len = sendto__( rns2Socket, sendParameters->data, sendParameters->length, 0, ( const sockaddr* ) & sendParameters->systemAddress.address.addr4, sizeof( sockaddr_in ) );
50 }
51 else
52 {
53 #if RAKNET_SUPPORT_IPV6==1
54 len = sendto__( rns2Socket, sendParameters->data, sendParameters->length, 0, ( const sockaddr* ) & sendParameters->systemAddress.address.addr6, sizeof( sockaddr_in6 ) );
55 #endif
56 }
57
58 if (len<0)
59 {
60 RAKNET_DEBUG_PRINTF("sendto failed with code %i for char %i and length %i.\n", len, sendParameters->data[0], sendParameters->length);
61 }
62
63
64 if (oldTTL!=-1)
65 {
66 setsockopt__(rns2Socket, sendParameters->systemAddress.GetIPPROTO(), IP_TTL, ( char * ) & oldTTL, sizeof ( oldTTL ) );
67 }
68
69 }
70 while ( len == 0 );
71 return len;
72 }
73
74 #endif // Windows, Linux, 360
75
76 #endif // file header
77
78 #endif // #ifdef RAKNET_SOCKET_2_INLINE_FUNCTIONS