- Timestamp:
- Nov 24, 2012, 2:11:41 PM (12 years ago)
- Branches:
- master
- Children:
- 94ebbd9
- Parents:
- e08572c
- Location:
- common
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
common/compiler.h
re08572c r0dde5da 1 1 #if defined _WIN64 2 2 #define WINDOWS 3 3 #elif defined _WIN32 4 4 #define WINDOWS 5 5 #elif defined __linux 6 6 #define LINUX 7 7 #elif defined __unix 8 8 #define LINUX 9 9 #elif defined __posix 10 10 #define LINUX 11 11 #endif -
common/message.cpp
re08572c r0dde5da 4 4 5 5 #if defined WINDOWS 6 7 6 #include <winsock2.h> 7 #include <WS2tcpip.h> 8 8 #elif defined LINUX 9 10 9 #include <sys/socket.h> 10 #include <netinet/in.h> 11 11 #endif 12 12 13 13 int sendMessage(NETWORK_MSG *msg, int sock, struct sockaddr_in *dest) 14 14 { 15 15 return sendto(sock, (char*)msg, sizeof(NETWORK_MSG), 0, (struct sockaddr *)dest, sizeof(struct sockaddr_in)); 16 16 } 17 17 18 18 int receiveMessage(NETWORK_MSG *msg, int sock, struct sockaddr_in *dest) 19 19 { 20 20 socklen_t socklen = sizeof(struct sockaddr_in); 21 21 22 23 22 // assume we don't care about the value of socklen 23 return recvfrom(sock, (char*)msg, sizeof(NETWORK_MSG), 0, (struct sockaddr *)dest, &socklen); 24 24 } -
common/message.h
re08572c r0dde5da 6 6 typedef struct 7 7 { 8 9 8 short type; 9 char buffer[256]; 10 10 } NETWORK_MSG; 11 11
Note:
See TracChangeset
for help on using the changeset viewer.