Mail Archives: cygwin/2001/01/09/17:51:47
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 AT cygwin DOT com
Red Hat, Inc.
--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple
- Raw text -