X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=octopi%2Flibrary%2Fsockets%2Fraw_socket.cpp;h=9b750e2ff4dedf0bf47ff268a49c20422ac31ac4;hb=f29812b042dede629e2c60469db039d30a8f2bad;hp=6b50fbe5189dbd342dc4e7ff966b601e3896037e;hpb=ee7596ce4d372d632f1d1555de9afd30b622bf29;p=feisty_meow.git diff --git a/octopi/library/sockets/raw_socket.cpp b/octopi/library/sockets/raw_socket.cpp index 6b50fbe5..9b750e2f 100644 --- a/octopi/library/sockets/raw_socket.cpp +++ b/octopi/library/sockets/raw_socket.cpp @@ -126,7 +126,11 @@ int raw_socket::ioctl(basis::un_int socket, int request, void *argp) const return ::ioctl(socket, request, argp); #endif #ifdef __WIN32__ - return ioctlsocket(socket, request, (un_long *)argp); + #ifdef _MSC_VER + return ioctlsocket(socket, request, (un_long *)argp); + #else + return ioctlsocket(socket, request, (un_int *)argp); + #endif #endif } @@ -213,36 +217,31 @@ int raw_socket::inner_select(basis::un_int socket, int mode, int timeout, FUNCDEF("inner_select"); // setup the file descriptor sets for the select. we check readability, // writability and exception status. -LOG("select A"); FD_ZERO(&read_list); FD_SET(socket, &read_list); -LOG("select B"); FD_ZERO(&write_list); FD_SET(socket, &write_list); -LOG("select C"); FD_ZERO(&exceptions); FD_SET(socket, &exceptions); -LOG("select D"); -timeval *farkle = new timeval; -LOG("select D.1"); -time_stamp *t = new time_stamp(); -LOG("select D.2"); - - timeval time_out; - time_stamp::fill_timeval_ms(time_out, timeout); + + timeval base_time_out; + time_stamp::fill_timeval_ms(base_time_out, timeout); // timeval has tv_sec=seconds, tv_usec=microseconds. +#if !defined(__GNU_WINDOWS__) + timeval *time_out = &base_time_out; +#elif defined(__GNU_WINDOWS__) + __ms_timeval win_time_out; + win_time_out.tv_sec = base_time_out.tv_sec; + win_time_out.tv_usec = base_time_out.tv_usec; + __ms_timeval *time_out = &win_time_out; +#endif -LOG("select E"); // select will tell us about the socket. int ret = ::select(socket + 1, (mode & SELECTING_JUST_WRITE)? NIL : &read_list, (mode & SELECTING_JUST_READ)? NIL : &write_list, - &exceptions, &time_out); -LOG("select F"); + &exceptions, time_out); int error = critical_events::system_error(); -LOG("select G"); - if (!ret) return 0; // nothing to report. if (ret == SOCKET_ERROR) { -LOG("select H"); switch (error) { // all real errors fall out to the error handling stuff. case SOCK_EFAULT: // intentional fall-through. @@ -264,7 +263,6 @@ LOG("select H"); #endif return 0; // not really an error. } -LOG("select I"); #ifdef DEBUG_RAW_SOCKET LOG(a_sprintf("socket %u had error %d in select: %s.", socket, error, _stack->tcpip_error_name(error).s())); @@ -272,7 +270,6 @@ LOG("select I"); return SI_ERRONEOUS; } -LOG("select J"); // if we got to here, then there are some things to report... return SI_BASELINE; } @@ -404,15 +401,23 @@ int raw_socket::select(int_array &read_sox, int_array &write_sox, FD_SET(sock, &write_list); } - timeval time_out; - time_stamp::fill_timeval_ms(time_out, timeout); + timeval base_time_out; + time_stamp::fill_timeval_ms(base_time_out, timeout); // timeval has tv_sec=seconds, tv_usec=microseconds. +#if !defined(__GNU_WINDOWS__) + timeval *time_out = &base_time_out; +#elif defined(__GNU_WINDOWS__) + __ms_timeval win_time_out; + win_time_out.tv_sec = base_time_out.tv_sec; + win_time_out.tv_usec = base_time_out.tv_usec; + __ms_timeval *time_out = &win_time_out; +#endif // select will tell us about the socket. int ret = ::select(highest + 1, (read_sox.length())? &read_list : NIL, (write_sox.length())? &write_list : NIL, - &exceptions, &time_out); + &exceptions, time_out); int error = critical_events::system_error(); if (ret == SOCKET_ERROR) {