X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=drivers%2Fcli%2Funix-netplay.c;h=747fa0009e3bcc2ef0abb4f2c00dbcc9c7259c4a;hb=2a6855a31daf79cad83545b1eeee646e10481e5e;hp=8e777dbc38050c9acfc5c153863b28ea4cc4b1e5;hpb=5232c20c0fa2c80964fe1d3f597c239bcf93d6fc;p=fceu.git diff --git a/drivers/cli/unix-netplay.c b/drivers/cli/unix-netplay.c index 8e777db..747fa00 100644 --- a/drivers/cli/unix-netplay.c +++ b/drivers/cli/unix-netplay.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -30,9 +31,8 @@ #ifndef socklen_t #define socklen_t int #endif -#ifdef NETWORK + static int Socket=-1; -#endif #include "main.h" #include "unix-netplay.h" @@ -42,7 +42,6 @@ int netplay=0; int FCEUD_NetworkConnect(void) { -#ifdef NETWORK struct sockaddr_in sockn; int TSocket; @@ -62,7 +61,7 @@ int FCEUD_NetworkConnect(void) if(bind(TSocket, (struct sockaddr *)&sockn, sizeof(sockn))<0) { close(TSocket); - puts("Error binding to socket."); + puts("Error binding to socket."); return(0); } if(listen(TSocket, 1)<0) @@ -73,7 +72,7 @@ int FCEUD_NetworkConnect(void) } { socklen_t len=sizeof(sockn); - + printf("Accepting connection on port %d...\n",Port); if((Socket=accept(TSocket,(struct sockaddr *)&sockn,&len))<0 ) { @@ -97,7 +96,7 @@ int FCEUD_NetworkConnect(void) return(0); } memcpy(&sockn.sin_addr,Host->h_addr,Host->h_length); - } + } printf("Attempting to connect to %s...\n",netplayhost); if( connect(TSocket, (struct sockaddr *)&sockn, sizeof(sockn)) <0 ) { @@ -107,8 +106,7 @@ int FCEUD_NetworkConnect(void) } Socket=TSocket; } -#endif - return(1); + return(1); } /* 0 on failure, 1 on success, -1 if it would block and blocking is not @@ -117,7 +115,6 @@ int FCEUD_NetworkConnect(void) int FCEUD_NetworkRecvData(uint8 *data, uint32 len, int block) { -#ifdef NETWORK if(block) { int t; @@ -144,28 +141,19 @@ int FCEUD_NetworkRecvData(uint8 *data, uint32 len, int block) } return(1); } -#else - return 1; -#endif } /* 0 on failure, 1 on success. This function should always block. */ int FCEUD_NetworkSendData(uint8 *Value, uint32 len) { -#ifdef NETWORK return(send(Socket,Value,len,0)==len); -#else - return 0; -#endif } void FCEUD_NetworkClose(void) { -#ifdef NETWORK if(Socket>0) close(Socket); Socket=-1; -#endif }