source: network-game/common/message.cpp@ ec48e7d

Last change on this file since ec48e7d was 0dde5da, checked in by dportnoy <dmp1488@…>, 12 years ago

Added a makefile for the client and made the WSA functions only work on Windows platforms

  • Property mode set to 100644
File size: 665 bytes
RevLine 
[d87708d]1#include "message.h"
2
3#include "compiler.h"
4
[e084950]5#if defined WINDOWS
[0dde5da]6 #include <winsock2.h>
7 #include <WS2tcpip.h>
[e084950]8#elif defined LINUX
[0dde5da]9 #include <sys/socket.h>
10 #include <netinet/in.h>
[d87708d]11#endif
12
13int sendMessage(NETWORK_MSG *msg, int sock, struct sockaddr_in *dest)
14{
[0dde5da]15 return sendto(sock, (char*)msg, sizeof(NETWORK_MSG), 0, (struct sockaddr *)dest, sizeof(struct sockaddr_in));
[d87708d]16}
17
18int receiveMessage(NETWORK_MSG *msg, int sock, struct sockaddr_in *dest)
19{
[0dde5da]20 socklen_t socklen = sizeof(struct sockaddr_in);
[d87708d]21
[0dde5da]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);
[e084950]24}
Note: See TracBrowser for help on using the repository browser.