Changeset 0dde5da in network-game for common/message.cpp
- Timestamp:
- Nov 24, 2012, 2:11:41 PM (12 years ago)
- Branches:
- master
- Children:
- 94ebbd9
- Parents:
- e08572c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note:
See TracChangeset
for help on using the changeset viewer.