How can I get into networking/servers/I don't even know what they're called using C++?

Hello!
So I've spent this whole day trying to figure this out. Problem is I don't even know where to start and don't know how any of network related things work.

I'm 1st year of college in computer science and I have a pretty good understanding of the language, but I recently found out that networking things are not included in courses.

What I want to do (short) is be able to access data on another platform and use it in a C++ code. Like get an int from somewhere (I don't know what that somewhere is, maybe a server). I have 0 idea where to start, I haven't been able to find anything useful so far.

I know this may not be strictly C++ related, but can someone please tell me where to start?
Thanks
The name of the topic you're looking for is "socket programming".

The canonical low-level sockets API is BSD/POSIX sockets. This is still used on Unix-like systems.
https://en.wikipedia.org/wiki/Berkeley_sockets
Windows has a near-clone of it called Winsock.

There's also Boost.Asio, which is cross-platform.
http://www.boost.org/doc/libs/

There are plenty of tutorials around, once you know what to look for. I'd usually recommend one to you, but I'm not familiar enough with the topic to do that.
Mobzzi - socket programming?
hmm would that involve developing kernel? sounds like very serious stuff, not so much tick tack toe or modulo to find odd or even number ;)
Fortunately no, unless I've made a mistake.
FWIW, by socket programming I meant "programming using a sockets API" instead of "programming a sockets API".

Hopefully I didn't tell OP he has to hack the kernel to get started. ;)
:DDD that would be fun.
well at least he will not jump into Linux kernel as its written in C and assembler ;)
It seems my reply from yesterday wasn't uploaded or was deleted for some reason.

Is this what all (or most) software that require to login use? Or multiplayer games, even with simple stuff like global highscore, not necessarily even in real time? It seems funny how I hadn't heard about it so far if that's the case :r
Have you thought about the middleware to use when connecting devices on a LAN Network? (Which is where I presume you will start, instead of WAN or www).
How about RakNet? Download the RakNet library. It's sort of gone under the radar for the past few years, but it works wonders in C++ Command line interface applications, when sending messages between PC's on a LAn, such as between two PC's in the same room.

SO much potential with it.
Oh , btw, if you didnt know, you dont have to use SOckets directly, you are supposed to use RakNet which will then automatically create its own definitions of sockets and what not.
Is this what all (or most) software that require to login use? Or multiplayer games, even with simple stuff like global highscore, not necessarily even in real time? It seems funny how I hadn't heard about it so far if that's the case :r

At some level, yes. A socket is simply a signal endpoint. Information is "written to" a socket and retrieved from others. The information that sockets transmit is structured according to the rules of a given protocol stack -- UDP or TCP/IP for example. Regarding authentication, additional protocols like SSL or TLS try to provide security by encrypting the data that's sent over the network.

The networking libraries I mentioned above simply supply a nicer interface to your computer's networking hardware, and implement those protocols for you.

The traditional "Hello World" program for network programming is the humble chat server/client pair. You can run the server on localhost and connect to it all from the same computer. There are again a number of tutorials for this sort of thing; it's not too hard. Maybe 200 lines of C or C++ between the two programs?

See, for example, these programs using Boost.Asio:
http://www.boost.org/doc/libs/1_63_0/doc/html/boost_asio/examples.html#boost_asio.examples.cpp11_examples
Last edited on
Topic archived. No new replies allowed.