cheremushkin
cheremushkin

Reputation: 101

How do I init socket in C++ without libraries

I need to init socket in C++ (GNU GCC) without libraries. When I Googled it, it suggested to use WinSock Library or something like this. How to do this? Thank you for answers.

Upvotes: 0

Views: 1022

Answers (3)

pcunite
pcunite

Reputation: 1197

The C++ standard does not provide for this. A good crossx library for this is C++ PTypes.

Upvotes: 0

Eric Y
Eric Y

Reputation: 1697

Sockets are allocated by the operating system so you'll need to interface with the OS in some way. In my experience with C++ using the GCC (I'm assuming Linux of some kind here) you will need to use the sys/sockets library. Some higher level abstractions of the sockets library exist but I've never found one I was too happy with.

Upvotes: 3

GManNickG
GManNickG

Reputation: 504133

You cannot. The C++ language as defined by the standard has no socket specification. To work with them, you necessarily have to use some implementation-specific libraries, like WinSock.

I would recommend you use Boost's ASIO library, which does all the hard and dirty work for you.

Upvotes: 8

Related Questions