|
Boost Users : |
Subject: Re: [Boost-users] socket reconnection
From: boost001 (oldyoungguy88_at_[hidden])
Date: 2008-12-09 15:42:58
My server will only handle one connection. No more. We plan to close socket
to get rid of all partial data in cases of error happened. Client
disconnected is one of the error cases.
We don't have problem in the initial connection. The only problem is on the
reconnection case. The actual error code we got is 9 not 1 (sorry about the
wrong info). 9 means "Bad file number".
Igor R wrote:
>
>>
>> I have an ASIO socket server. I need to close the socket and then listen
>> to
>> the socket again if client disconnected from server.
>>
>> <...>
>
>
>
>> asio_acceptorPtr->close(error_closing);
>> asio_socketPtr->shutdown(tcp::socket::shutdown_both, error_closing);
>> asio_socketPtr->close(error_closing);
>>
>> in the process reopen the socket, I did the following in order:
>>
>> asio_socketPtr->open(protocol, error_connecting);
>> asio_acceptorPtr->open(protocol, error_connecting);
>
>
> Why do you need to close the acceptor? Can't you continue accepting
> incoming
> connections with the same acceptor?
> Why do you need to close the socket? You said that the client already
> disconnected, so your server socket is closed anyway.
> Anyway, if your asio_socketPtr is a server socket that accepts an incoming
> connection, then you have to pass it to the acceptor's async_accept/accept
> member functions - the acceptor will "open" the socket.
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
-- View this message in context: http://www.nabble.com/socket-reconnection-tp20922241p20923202.html Sent from the Boost - Users mailing list archive at Nabble.com.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net