Fixed pointer warnings on POSIX and win32

This commit is contained in:
Michael Jumper 2011-04-21 23:49:14 -07:00
parent 4e1e693c2d
commit d1759acca9

View File

@ -45,9 +45,11 @@
#ifdef __MINGW32__ #ifdef __MINGW32__
#include <winsock2.h> #include <winsock2.h>
typedef int socklen_t; typedef int socklen_t;
typedef char* sockopt_p;
#else #else
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/in.h> #include <netinet/in.h>
typedef void* sockopt_p;
#endif #endif
#include <errno.h> #include <errno.h>
@ -119,7 +121,7 @@ int main(int argc, char* argv[]) {
/* Server */ /* Server */
int socket_fd; int socket_fd;
struct sockaddr_in server_addr; struct sockaddr_in server_addr;
const char opt_on[] = {1}; int opt_on = 1;
/* Client */ /* Client */
struct sockaddr_in client_addr; struct sockaddr_in client_addr;
@ -179,7 +181,7 @@ int main(int argc, char* argv[]) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
if (setsockopt(socket_fd, SOL_SOCKET, SO_REUSEADDR, opt_on, sizeof(opt_on))) { if (setsockopt(socket_fd, SOL_SOCKET, SO_REUSEADDR, (sockopt_p) &opt_on, sizeof(opt_on))) {
fprintf(stderr, "Warning: Unable to set socket options for reuse: %s\n", lasterror()); fprintf(stderr, "Warning: Unable to set socket options for reuse: %s\n", lasterror());
} }