Changeset 0dde5da in network-game for common


Ignore:
Timestamp:
Nov 24, 2012, 2:11:41 PM (12 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
94ebbd9
Parents:
e08572c
Message:

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

Location:
common
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • common/compiler.h

    re08572c r0dde5da  
    11#if defined _WIN64
    2         #define WINDOWS
     2   #define WINDOWS
    33#elif defined _WIN32
    4         #define WINDOWS
     4   #define WINDOWS
    55#elif defined __linux
    6         #define LINUX
     6   #define LINUX
    77#elif defined __unix
    8         #define LINUX
     8   #define LINUX
    99#elif defined __posix
    10         #define LINUX
     10   #define LINUX
    1111#endif
  • common/message.cpp

    re08572c r0dde5da  
    44
    55#if defined WINDOWS
    6         #include <winsock2.h>
    7         #include <WS2tcpip.h>
     6   #include <winsock2.h>
     7   #include <WS2tcpip.h>
    88#elif defined LINUX
    9         #include <sys/socket.h>
    10         #include <netinet/in.h>
     9   #include <sys/socket.h>
     10   #include <netinet/in.h>
    1111#endif
    1212
    1313int sendMessage(NETWORK_MSG *msg, int sock, struct sockaddr_in *dest)
    1414{
    15         return sendto(sock, (char*)msg, sizeof(NETWORK_MSG), 0, (struct sockaddr *)dest, sizeof(struct sockaddr_in));
     15   return sendto(sock, (char*)msg, sizeof(NETWORK_MSG), 0, (struct sockaddr *)dest, sizeof(struct sockaddr_in));
    1616}
    1717
    1818int receiveMessage(NETWORK_MSG *msg, int sock, struct sockaddr_in *dest)
    1919{
    20         socklen_t socklen = sizeof(struct sockaddr_in);
     20   socklen_t socklen = sizeof(struct sockaddr_in);
    2121
    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);
     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);
    2424}
  • common/message.h

    re08572c r0dde5da  
    66typedef struct
    77{
    8         short type;
    9         char buffer[256];
     8   short type;
     9   char buffer[256];
    1010} NETWORK_MSG;
    1111
Note: See TracChangeset for help on using the changeset viewer.