将(和应该)有在C + + 11插槽? [英] Will (and should) there be sockets in C++11?

查看:113
本文介绍了将(和应该)有在C + + 11插槽?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

新的C ++ 11是否包含任何套接字库?所以一个人可以做一些 std :: socket -ish?



std :: thread 将被添加,感觉好像应该添加套接字。 C语言的套接字是一个痛苦...他们感觉非常反直觉。



无论如何:C ++ 11中有C ++套接字(googled it can couldn'找到答案)?如果不是,他们有任何计划添加这个?为什么(/为什么不)?

解决方案

不,至于不久的将来,C ++标准委员会已创建了一个研究组即正在开发网络层提案。它看起来像他们要自下而上的方法,从一个基本的套接字层开始,然后构建HTTP / etc支持。 他们希望在10月委员会会议上介绍基本的套接字提议。



至于为什么他们没有把它放入C ++ 11,那是纯粹的投机。






如果你想要我的意见,这是因为这个原因。



它做了一些事情,它有一个特定的功能,然后你可以选择库的两个原因之一。一个原因是因为该库需要必要来实现您的代码。另一种是因为它在实现代码时总是有用的



对于特定程序的设计是非常困难的说,我绝对必须使用std :: vector来保存这个项目列表!程序的设计不是具体的。如果你正在做一个网络浏览器,浏览器的想法不在乎它是否在std :: vector,std :: list或用户创建的对象中保存其选项卡。现在,一些设计可以强烈建议某些数据结构。但是设计很少会明确地说明低级的像std :: list是非常重要的。



std :: list可以在任何程序。 as std :: vector,std :: deque等。



然而,如果你正在做一个web浏览器,瓶装在这个设计是网络。您必须使用网络库或自己编写网络图层。这是这个想法的基本要求。



我使用的前一种类型的术语,对于可以在任何东西使用的库,是实用程序库。 p>

线程是一个实用程序库。设计可能鼓励通过需要响应用户的线程,但有方法响应无需抢先的多线程。因此,在大多数情况下,线程是一个实现选择。因此,线程是一种实用程序。



网络不是 。如果您的设计特别需要,您只能使用网络。你不会决定把网络转移到程序中。它不是实现细节;这是一个设计要求。



这是我的意见,标准的C / C ++库应该只实现实用程序。这也是为什么我反对其他重量级的想法如XML解析器等等。它是没有错的其他库有这些东西,但对于C和C ++,这些不是好的选择。


Is the new C++11 going to contain any socket library? So that one could do something std::socket-ish?

Seeing as how std::thread will be added, it feels as if sockets should be added as well. C-style sockets are a pain... They feel extremely counter-intuitive.

Anyways: Will there be C++ sockets in C++11 (googled it but couldn't find an answer)? If not, are their any plans on adding this? Why (/ why not)?

解决方案

No, it is not. As for the near future, the C++ standards committee has created a study group that is developing a networking layer proposal. It looks like they're going for a bottom-up approach, starting with a basic socket layer, then building HTTP/etc support on top of that. They're looking to present the basic socket proposal at the October committee meeting.

As for why they didn't put this into C++11, that is purely speculative.


If you want my opinion on the matter, it's for this reason.

If you are making a program that does something, that has a specific functionality to it, then you can pick libraries for one of two reasons. One reason is because that library does something that is necessary to implement your code. And the other is because it does something that is helpful in implementing code in general.

It is very difficult for a design for a particular program to say, "I absolutely must use a std::vector to hold this list of items!" The design for a program isn't that specific. If you're making a web browser, the idea of a browser doesn't care if it holds its tabs in a std::vector, std::list, or a user-created object. Now, some design can strongly suggest certain data structures. But rarely does the design say explicitly that something low-level like a std::list is utterly essential.

std::list could be used in just about any program. As can std::vector, std::deque, etc.

However, if you're making a web browser, bottled within that design is networking. You must either use a networking library or write a networking layer yourself. It is a fundamental requirement of the idea.

The term I use for the former type, for libraries that could be used in anything, is "utility" libraries.

Threading is a utility library. Design might encourage threading through the need to respond to the user, but there are ways to be responsive without preemptive multithreading. Therefore, in most cases, threading is an implementation choice. Threading is therefore a utility.

Networking is not. You only use networking if your design specifically calls for it. You don't decide to just dump networking into a program. It isn't an implementation detail; it is a design requirement.

It is my opinion that the standard C/C++ library should only implement utilities. It's also why I'm against other heavyweight ideas like XML parsers, etc. It isn't wrong for other libraries to have these things, but for C and C++, these are not good choices.

这篇关于将(和应该)有在C + + 11插槽?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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