From d5591d9df67a1425a8c05f22cbde430c4a93627f Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Fri, 5 Jul 2002 18:26:23 +0000 Subject: * fhandler.h (UNCONNECTED): New define. (CONNECT_PENDING): Ditto. (CONNECTED): Ditto. (class fhandler_socket): Add member `had_connect_or_listen'. Add member functions `is_unconnected', `is_connect_pending' and `is_connected'. * fhandler_socket.cc (fhandler_socket::connect): Set member `had_connect_or_listen' according to return code of WinSock call. (fhandler_socket::listen): Ditto. * net.cc (cygwin_getsockopt): Modify SO_ERROR return value in case of socket with pending connect(). * select.cc (peek_socket): Only add socket to matching fd_set if it's not "ready". Call WINSOCK_SELECT only if at least one socket is in one of the fd_sets. (start_thread_socket): Only add socket to matching fd_set if it's not "ready". (fhandler_socket::select_write): Set write_ready to true also if socket isn't connected or listening. --- winsup/cygwin/fhandler.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'winsup/cygwin/fhandler.h') diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index 5727d24ab..980957a67 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -101,6 +101,10 @@ enum both flags are set. */ #define O_NONBLOCK_MASK (O_NONBLOCK | OLD_O_NDELAY) +#define UNCONNECTED 0 +#define CONNECT_PENDING 1 +#define CONNECTED 2 + extern const char *windows_device_names[]; extern struct __cygwin_perfile *perfile_table; #define __fmode (*(user_data->fmode_ptr)) @@ -367,6 +371,7 @@ class fhandler_socket: public fhandler_base HANDLE secret_event; struct _WSAPROTOCOL_INFOA *prot_info_ptr; char *sun_path; + int had_connect_or_listen; public: fhandler_socket (); @@ -380,6 +385,10 @@ class fhandler_socket: public fhandler_base void set_shutdown_read () {FHSETF (SHUTRD);} void set_shutdown_write () {FHSETF (SHUTWR);} + bool is_unconnected () {return had_connect_or_listen == UNCONNECTED;} + bool is_connect_pending () {return had_connect_or_listen == CONNECT_PENDING;} + bool is_connected () {return had_connect_or_listen == CONNECTED;} + int bind (const struct sockaddr *name, int namelen); int connect (const struct sockaddr *name, int namelen); int listen (int backlog); -- cgit v1.2.3