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
  • 56,458
  • 54
  • 195
  • 288

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
  • 43,810
  • 29
  • 138
  • 169
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,379
  • 7
  • 57
  • 73
0

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

dirkgently
  • 108,024
  • 16
  • 131
  • 187
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
  • 26,726
  • 31
  • 139
  • 202
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,934
  • 11
  • 59
  • 95