Will there be (and should) be sockets in C ++ 11?

Will the new C ++ 11 contain any socket library? So that you can do something std::socket -ish?

Seeing how std::thread will be added, it seems that sockets should also be added. C style sockets are a pain ... They feel extremely intuitive.

In any case: will there be C ++ sockets in C ++ 11 (googled, but could not find the answer)? If not, are you planning to add this? Why (/ why not)?

+56
c ++ c ++ 11 sockets
Jul 09 '11 at 23:40
source share
5 answers

No, it is not. For the near future, the C ++ Standards Committee has created a research group that is developing a network-level proposal . It looks like they are taking an upward approach, starting at the base level of the socket, and then building support for HTTP / etc. They want to present the main proposal of the socket at the October committee meeting.

As for why they did not put this in C ++ 11, this is purely speculative.




If you want my opinion on this issue, then for this reason.

If you create a program that does something, it has certain functions, you can choose libraries for one of two reasons. One reason is that this library does what it takes to implement your code. And the other - because he does something useful when implementing code in general.

It is very difficult for the design for a particular program to say: "I absolutely must use std::vector to store this list of elements!" The design of the program is not so specific. If you are creating a web browser, the idea of โ€‹โ€‹a browser does not bother if it contains its tabs in std::vector , std::list or a user-created object. Now, some designs may strongly suggest certain data structures. But rarely does design explicitly say that something low-level, like std::list , is extremely important.

std::list can be used for almost any program. How can std::vector , std::deque , etc.

However, if you are creating a web browser, bottled as part of this project, it is a network. You must either use the network library or write the network layer yourself. This is a fundamental requirement of this idea.

The term that I use for the former type, for libraries that can be used in all cases, are "useful" libraries.

Threading is a utility library. Design can stimulate flows through the need to respond to the user, but there are ways to respond without proactive multithreading. Therefore, in most cases, threads are the choice of implementation. Threading is a utility.

Not online. You only use the network if your design specifically requires it. You do not decide to simply drop networks into the program. This is not an implementation detail; this is a design requirement.

I believe that the standard C / C ++ library should only implement utilities. This is also why I am against other heavyweight ideas such as XML parsers, etc. This is not because other libraries have these things, but for C and C ++ this is not the best choice.

+48
Jul 09 2018-11-11T00:
source share

I think this should happen, as many other popular languages โ€‹โ€‹support socket operations as part of the language (they do not force the user to use any OS-specific API). If we already have file streams for reading / writing local files, I donโ€™t understand why we donโ€™t have a way to transfer data with sockets.

+9
Jul 16 '11 at 3:15
source share

In C ++ 11 there will be no sockets. The difference between streams and sockets is that streams include additional guarantees when ordering, if your program is associated with streams. For a single-core platform, then C ++ 11 does not require your processor to load an additional core. Sockets, on the other hand, will be ... difficult to implement in a portable and elegant way to expose systems that don't have them.

+4
Jul 09 '11 at 23:45
source share

In C ++ 0x will not be. There are suggestions for adding them to a future version.

The number of new things in C ++ 0x had to be limited in order to give time on the committee to deal with all this.

+1
Jul 09 2018-11-11T00:
source share

The wikipedia page for C ++ 0x is usually pretty relevant, and the section on changes to the library does not seem to mention sockets.

0
Jul 09 '11 at 23:44
source share



All Articles