[quake3] Mergine unix_net.c and win_net.c questions

Diego de Estrada diego1609 at gmail.com
Wed Aug 15 20:41:52 EDT 2007


Maybe just using SDL_net would be a clean way to do this?

On 8/15/07, Ryan C. Gordon <icculus at icculus.org> wrote:
>
> > I thought about #defining SOCKET_ERROR -1 and stuff like that, but I
> > wasn't sure if that would be acceptable. Is it?
>
> Most games I've worked on end up #define'ing and typedef'ing a handful
> of things at the start to unify WinSock and BSD differences, and then
> use mostly the same code after that:
>
> typedef int SOCKET;
> typedef struct hostent HOSTENT;
> typedef in_addr IN_ADDR;
> typedef struct sockaddr SOCKADDR;
> typedef struct sockaddr_in SOCKADDR_IN;
> typedef struct linger LINGER;
> typedef struct timeval TIMEVAL;
> typedef TCHAR* LPSTR;
> typedef socklen_t SOCKLEN;
> #define INVALID_SOCKET          -1
> #define SOCKET_ERROR            -1
> #define WSAEWOULDBLOCK          EAGAIN
> #define WSAEINPROGRESS          EINPROGRESS
> #define WSAENOTSOCK             ENOTSOCK
> #define WSATRY_AGAIN            TRY_AGAIN
> #define WSAHOST_NOT_FOUND       HOST_NOT_FOUND
> #define WSANO_DATA              NO_ADDRESS
> #define LPSOCKADDR              sockaddr*
> #define WSAECONNRESET           ECONNRESET
> #define closesocket             close
> #define ioctlsocket             ioctl
> #define WSAGetLastError()       errno
>
> (etc)
>
> ...these can map from BSD sockets to WinSock too, of course, but I
> usually end up moving WinSock code to Unix and not the other way around.
>
> The number of #ifdef's past that block tends to be extremely minimal.
>
> --ryan.
>
>
> ---
> To unsubscribe, send a blank email to quake3-unsubscribe at icculus.org
> Mailing list archives: http://icculus.org/cgi-bin/ezmlm/ezmlm-cgi?50
>
>
>



More information about the quake3 mailing list