#ifdef __APPLE__
#include <fcntl.h>
#endif
-#ifdef __UNIX__
+//#ifdef __UNIX__
#include <arpa/inet.h>
#include <errno.h>
#include <netinet/tcp.h>
#include <sys/socket.h>
#include <unistd.h>
#define OPTYPE (void *)
-#endif
-#ifdef __WIN32__
- #define OPTYPE (char *)
-#endif
+//#endif
+//#ifdef __WIN32__
+// #define OPTYPE (char *)
+//#endif
using namespace basis;
using namespace loggers;
const basis::un_int NON_BLOCKING = FIONBIO;
const basis::un_int IOCTL_READ = FIONREAD;
-#ifdef __WIN32__
/*
+#ifdef __WIN32__
// defined by winsock header but not present in the winsock dll.
int PASCAL FAR __WSAFDIsSet(SOCKET fd, fd_set FAR *the_set)
{
return true;
return false;
}
-*/
#endif
+*/
//////////////
int raw_socket::close(basis::un_int &socket)
{
int to_return = 0;
-#ifdef __WIN32__
- to_return = closesocket(socket);
-#endif
-#ifdef __UNIX__
+//#ifdef __WIN32__
+// to_return = closesocket(socket);
+//#endif
+//#ifdef __UNIX__
to_return = ::close(socket);
-#endif
+//#endif
socket = 0;
return to_return;
}
int raw_socket::ioctl(basis::un_int socket, int request, void *argp) const
{
-#ifdef __UNIX__
+//#ifdef __UNIX__
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
+*/
}
bool raw_socket::set_non_blocking(basis::un_int socket, bool non_blocking)
fd_set_wrapper &read_list, fd_set_wrapper &write_list,
fd_set_wrapper &exceptions) const
{
-#ifdef DEBUG_RAW_SOCKET
FUNCDEF("inner_select");
-#endif
// setup the file descriptor sets for the select. we check readability,
// writability and exception status.
FD_ZERO(&read_list); FD_SET(socket, &read_list);
FD_ZERO(&write_list); FD_SET(socket, &write_list);
FD_ZERO(&exceptions); FD_SET(socket, &exceptions);
- timeval time_out = time_stamp::fill_timeval_ms(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(socket + 1,
- (mode & SELECTING_JUST_WRITE)? NIL : &read_list,
- (mode & SELECTING_JUST_READ)? NIL : &write_list,
- &exceptions, &time_out);
+ (mode & SELECTING_JUST_WRITE)? NULL_POINTER : &read_list,
+ (mode & SELECTING_JUST_READ)? NULL_POINTER : &write_list,
+ &exceptions, time_out);
int error = critical_events::system_error();
-
if (!ret) return 0; // nothing to report.
if (ret == SOCKET_ERROR) {
case SOCK_ENETDOWN: // intentional fall-through.
case SOCK_EINVAL: // intentional fall-through.
case SOCK_EINTR: // intentional fall-through.
-#ifdef __WIN32__
+/* #ifdef __WIN32__
case SOCK_NOTINITIALISED: // intentional fall-through.
-#endif
+#endif */
case SOCK_ENOTSOCK:
break;
FD_SET(sock, &write_list);
}
- timeval time_out = time_stamp::fill_timeval_ms(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);
+ (read_sox.length())? &read_list : NULL_POINTER,
+ (write_sox.length())? &write_list : NULL_POINTER,
+ &exceptions, time_out);
int error = critical_events::system_error();
if (ret == SOCKET_ERROR) {
case SOCK_ENETDOWN: // intentional fall-through.
case SOCK_EINVAL: // intentional fall-through.
case SOCK_EINTR: // intentional fall-through.
-#ifdef __WIN32__
+/*#ifdef __WIN32__
case SOCK_NOTINITIALISED: // intentional fall-through.
-#endif
+#endif*/
case SOCK_ENOTSOCK:
break;