[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [Libevent-users] Proper socket shutdown.



On Thu, Nov 4, 2010 at 11:49 AM, Kelly Brock <Kerby@xxxxxxxxxxx> wrote:
 [...]
>        Got the fix.  Fricken IOCP strangness bites again.  You just have to
> insert a call to:
>
>        int err = setsockopt( fd,
>                SOL_SOCKET,
>                SO_UPDATE_ACCEPT_CONTEXT,
>                (char *)&listener,
>                sizeof(listener) );

Wow, nice hunting.

>        The fd is the socket you accepted from the call to AcceptEx and the
> listener is of course the listener socket.  I did this in the listener
> callback and don't know exactly where in libevent proper it should be added.
> If you point me in the correct direction I'll post a patch if you want, or
> you can drop it in there pretty easy.

I think you'd want to handle it in listener.c, in
accepted_socket_invoke_user_cb(), right after the GetAcceptExSockaddrs
call.

>        With this fix, shutdown and WSASendShutdown worked fine and I was
> able to get clean disconnects as desired.

Nice!

-- 
Nick
***********************************************************************
To unsubscribe, send an e-mail to majordomo@xxxxxxxxxxxxx with
unsubscribe libevent-users    in the body.