关于使用 Boost ASIO 进行套接字编程的基本问题
我对套接字编程比较陌生。我目前正在尝试 boost::asio 提供的示例。我有一个关于套接字的一般问题。
假设我正在使用 tcp::socket.connect(endpoint,error) 函数连接远程端点。我可以使用同一个套接字对象发送和接收数据,还是必须创建另一个套接字对象来发送数据?
谢谢, 德文德拉
I am relatively new to socket programming. I am currently trying examples provided with boost::asio. I have a general question about sockets.
Lets say I am connecting a remote endpoint using tcp::socket.connect(endpoint,error) function. Can I both send and receive using the same socket object or do I have to create another socket object to send the data?
Thanks,
Devendra
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您可以在同一个套接字上发送和接收。例如,客户端套接字的典型用途是根据协议进行连接、发送一些数据、读取一些数据等。
了解 boost asio 的有用链接是 Boris Schäling 的免费电子书:http:// en.highscore.de/cpp/boost/index.html
Yes, you can both send and recv on the same socket. E.g a typical use of a client socket would be to connect, send some data, read some data, etc depending on the protocol.
A useful link to learn about boost asio would be a free eBook by Boris Schäling: http://en.highscore.de/cpp/boost/index.html