C++ 套接字编程
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3509011/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Socket Programming in C++
提问by Swapnil Gupta
Can anybody provide me some sample example on Client and server connection using sockets in C++. I have gone through some tutorials now i want to implement it. How to start ?
任何人都可以为我提供一些有关使用 C++ 中的套接字的客户端和服务器连接的示例示例。我已经阅读了一些教程,现在我想实现它。如何开始?
回答by codaddict
You can find a working client-server program here: Beej's Guide to Network Programming
你可以在这里找到一个有效的客户端-服务器程序:Beej's Guide to Network Programming
回答by Tony Delroy
There is no socket API in the C++ Standard. The POSIX C API is fairly portable (the GNU libC documentation provides examples of UDP and TCP clients and servers that I usually turn to when I'm scratching together another server), or you could use the Boost.ASIO library for a more C++ experience....
C++ 标准中没有套接字 API。POSIX C API 是相当可移植的(GNU libC 文档提供了 UDP 和 TCP 客户端和服务器的示例,当我在另一台服务器上拼凑时,我通常会使用这些示例),或者您可以使用 Boost.ASIO 库以获得更多的 C++ 体验....