2

I am a begginer C++ programmer. In C#, I used the System.Net.Sockets.Socket class, which represents a networking socket, to create/connect a server. How can I do the same thing in C/C++? Are there any classes like this?

Alon Gubkin
  • 54,770
  • 52
  • 188
  • 285

5 Answers5

7

In windows theres a library called winsock.dll.

In Unix, you can use unix sockets

Then, theres boost sockets

beej guide to internet sockets

windows sockets

boost networking

Tom
  • 41,802
  • 29
  • 133
  • 165
1

I would recommend reading beej's guide to Network Socket programming. It is a really good source full of good explanations.

Robert Massaioli
  • 13,101
  • 7
  • 54
  • 72
0

Sockets are not a fundamental part of either C or C++. If you are on Windows, start off with Winsock.

dirkgently
  • 104,737
  • 16
  • 128
  • 186
0

I've done a little bit with libcurl, this question has tonnes of answers:

Best C/C++ Network Library

...OK to be fair, libcurl doesn't work directly with sockets, so maybe it's not what you're looking for. But it does support a great many protocols.

Community
  • 1
  • 1
FrustratedWithFormsDesigner
  • 25,952
  • 31
  • 133
  • 193
0

Since you used System.Net.Sockets.Socket in C#, you can use System::Net::Sockets::Socket in C++/CLI--a language which is a .NET flavor of C++.

Ðаn
  • 10,679
  • 11
  • 60
  • 94