ASIO client server shutdown

限于喜欢 提交于 2019-12-25 00:11:06

问题


Please refer to the ASIO examples at : http://www.boost.org/doc/libs/1_57_0/doc/html/boost_asio/examples/cpp03_examples.html

The connection class code is at : http://www.boost.org/doc/libs/1_57_0/doc/html/boost_asio/example/cpp03/http/server/connection.cpp

This class has a stop() function which calls stop on socket that has been created corresponding to a connection request to server (from void server::start_accept())

The client code resides at : http://www.boost.org/doc/libs/1_57_0/doc/html/boost_asio/example/cpp03/http/client/sync_client.cpp

This class also creates a socket at the client end, but this code does not close the socket.

My question is that there are 2 sockets that are opened: from client to server and vice-a-versa

So, I have 2 questions :

a) Is just closing the socket which the server has opened sufficient or should we also call close on the socket inside the client code ?

b) Should we call shutdown on socket before calling close ?

来源:https://stackoverflow.com/questions/48267854/asio-client-server-shutdown

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!