Socket API或C ++库? [英] Socket API or library for C++?

查看:359
本文介绍了Socket API或C ++库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近已经越来越多地进入C ++。我做了一些(非常小)套接字编程与C,但一直有兴趣做一些工作与C ++。我只能找到参考/教程基于C的套接字实现。有什么原因吗?我知道,或相信我知道你可以使用C的C库的库,但不知道。

I recently have been getting more into C++. I have done some (very minimal) socket programming with C, but have been interested in doing some work with C++. I have only been able to find reference/tutorials on C based socket implementations. Is there a reason for this? I know, or believe I know that you can use the C socket libraries for C++, but am not sure.

有一个C ++套接字库,更频繁地使用其他?这不是一个主观的问题,我实际上想找出什么Socket API的/ C ++的。

Is there a C++ socket library that is used more often then others? This isn't a subjective question, I am actually looking to find out what the Socket API's/libraries are for C++.

我在套接字编程和C ++方面相当新,所以请没有答案会让我陷入循环。

I am fairly new at socket programming and C++, so please no answers that will throw me for a loop.

谢谢

推荐答案

在这里,我试图回答一些具体的事实问题,

Here I'm attempting to answer some of your specific, factual questions to which I have something to contribute.

是的,您可以使用C ++中的任何C套接字库。如果因为链接器报告了您要使用的库函数的未定义引用而无法开箱即用,那么可以通过编辑来修复它。在所有函数和全局变量声明前加上 externC文件。

Yes, you can use any C socket library in C++. If it doesn't work out-of-the-box because the linker reports an undefined reference for the library functions you want to use, then can fix it by editing the .h file(s) of the library, adding extern "C" in front of all function and global variable declarations.

要查找库,请转到 http://freshmeat.net/ ,然后搜索 C ++套接字 C套接字。这是我发现 C ++ socket

To find libraries, go to http://freshmeat.net/ , and search for C++ socket or C socket. Here is what I've found for C++ socket:

  • Socket++.
  • ENUt.
  • LibSylph.
  • CPPSocket might also work for you, although the last update was in 2003.
  • SocketW is similarly old: last update in 2003.

正如Raphael在他的回答中提到的,您可能会发现Qt库的套接字部分很有用。请参见 QTCpSocket 以供参考,以及 fortune client 例如代码。

As Raphael has mentioned in his answer, you might find the socket part of the Qt library useful. See QTCpSocket for reference, and the fortune client for example code.

a href =http://www.boost.org/doc/libs/release/doc/html/boost_asio.html =nofollow> Boost.Asio 已显示在我的脑海中,但它可能

Also Boost.Asio has popped to my mind, but it might have too much abstraction and low-level details exposed for you.

在freshmeat上搜索 C socket 你可能会发现一个C库比任何C ++库都更好。

Do your search for C socket on freshmeat, you may find a C library which suits better than any C++ library.

这篇关于Socket API或C ++库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆