This is the mail archive of the
cygwin@sources.redhat.com
mailing list for the Cygwin project.
Re: Winsock Bug Workaround - closing windows sockets
- To: cygwin <cygwin at cygwin dot com>
- Subject: Re: Winsock Bug Workaround - closing windows sockets
- From: Corinna Vinschen <cygwin at cygwin dot com>
- Date: Tue, 9 Jan 2001 23:41:13 +0100
- References: <001801c07b31$d72a4720$904bb4ca@private>
On Wed, Jan 10, 2001 at 10:19:14AM -0800, David McNab wrote:
> #ifdef __CYGWIN__
> int client_sock_flags;
> struct linger lingeropt;
>
> /* flush out the client socket - set it to blocking, then write to it */
> client_sock_flags=fcntl(client,F_GETFL,0);
> if(client_sock_flags!=-1)
> /* enable blocking */
> fcntl(client,F_SETFL,client_sock_flags & ~O_NONBLOCK);
>
> /* sent it a byte - guaranteed to block - ensure delivery of prior data */
> /* yeah - this is a bit paranoid - try without this at first */
> /* write(client, "\n", 1); */
>
> /* this is the guts of the workaround for Winsock close bug */
> shutdown(client, 1);
>
> /* enable lingering */
> lingeropt.l_onoff = 1;
> lingeropt.l_linger = 15;
> setsockopt(client, SOL_SOCKET, SO_LINGER, &lingeropt, sizeof(lingeropt));
> #endif
>
> /* Winsock bug averted - now we're safe to close the socket */
> close(client);
Weeks ago I tried to implement something similar in
fhandler_socket::close() itself to get rid of that problem
but without luck. This is a good solution for applications
but it's not generalizable, unfortunately.
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Developer mailto:cygwin@cygwin.com
Red Hat, Inc.
--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple