C++ Network Programming

Pages: 12
I'm getting a bit confused so my understanding is
1.pick a socket library(sfml boost etc...)
2.programme in a appropriate protocol(tcp udp)

So once I pick a socket library I have to learn the syntax and concepts of that library then get a tutorial on a protocol

Thank you for all the replies btw
MIZ:

Yeah, use sockets. But, do not inline your code. Since you're a beginner, I feel obligated to meantion this, since I remember that I, as a beginner, inlined a lot of things I probably shouldn't have. If you can make somthing another function, do it. You're life will be made easier for it, especially with socket programming. It's all about centralizing the codebase, and writing code once (as opposed to more than once, and in multiple places).
Little Bobby Tales wrote:
they literally arent, actually, otherwise windows would completely drop the winapi and pick up posix
Note how I said "BSD sockets."

Winsock isn't based off of POSIX sockets. It's based off of BSD sockets which are not technically part of the POSIX specification. I don't think you understand the difference between the two, which is a problem.

Also, even if they were based off of POSIX sockets, why would they have to adopt the POSIX standard? Windows' way of doing things is it's own standard. It's large enough that it really doesn't matter what standard that they use and what they don't.

And now that I think of it... Linux uses POSIX features, yet it isn't technically POSIX system. Why is this? By your logic, since it supports POSIX features, it should be 100% compliant with POSIX itself!

actually, it has a lot more baggage than POSIX sockets. this is due to the fact that posix sockets and winsock were created for different reasons
Winsock's sole purpose of creation was to be a Windows implementation of BSD sockets. It was meant to attract *nix developers to Windows. It was created with a large amount of compatibility in mind.

POSIX sockets are literally just BSD sockets with a few slight alterations, meant to standardize sockets on POSIX-compatible systems.

I don't really know where you're getting your information from, but it says that right on Microsoft's website.

there are more than one kind of raw sockets. have you used sys/inet.h? those are posix sockets (iirc. its some sort of standard). that *is* a light layer over BSD sockets. SFML providesa a great deal more of an abstraction.
No it's not a light layer over BSD sockets. It's a POSIX system's way of implementing them (well not technically. POSIX sockets are really a completely different API that was based off of BSD sockets, but for all intents and purposes they're the same).
______________________________________________________________________

S G H wrote:
@Avilius: Making an asynchronous socket's been a nightmare my first time.
It might have been because you were inexperienced with networking in general at that time.

It's like saying "I first learned Clarinet, which was hard. I then picked up Saxophone and it was way easier!"

You've already learned the basics of music theory and how to play a woodwind instrument (not to mention a lot of other things, such as the fingerings with some notes, and with some Saxophone flavors, the same key); I'd sure hope that it's easy to learn!

Also my SFML suggestion isn't for highlevel networking, but for portable lowlevel-ish networking. This allows him to understand how protocols work while being sure the networking code is correct for every system.
Okay I understand. That's a perfectly valid reason, however, You could do that even without SFML with about twenty minutes of work.

And even if that wasn't the case, why are you even worrying about portability at this stage? I'm not saying that you should go out of your way to use platform-specific functionality whenever possible, but if you're bending over backwards to just to make sure something works on Linux, you're doing it wrong!

Portability should be your last concern while learning a new field in programming!
Last edited on
MIZ wrote:
So once I pick a socket library I have to learn the syntax and concepts of that library then get a tutorial on a protocol
Although TCP and UDP are protocols, you won't be worrying about them; you'll be using both to implement your own protocol on top of them. Tutorials won't really help you very much as protocols are very specific to a purpose.
It might have been because you were inexperienced with networking in general at that time.

Meh, when I first got into asynchronous network programming (Boost.Asio) I also struggled a lot and I had quite a bit of networking knowledge already. It's just a strange way to think so it takes a bit to get used to it. But once you figure it out, it's almost common sense. Everything I've read, this experience is pretty normal. So if you grasped it right away, that's great, but it seems you are not the norm :)
Even though I'm very confused I think I'll start getting better once I get my hands on the sfml or boost asio socket libraries

If it's not to much of a hassle can you guys answer my other post about tutorials on this site wether it's good or not and what learning resource I should move on to next
@ResidentBiscuit
Fair enough.

MIZ wrote:
If it's not to much of a hassle can you guys answer my other post about tutorials on this site wether it's good or not and what learning resource I should move on to next
Oh, erm... sorry.

I recommend Beej's Guide to Network Programming ( http://beej.us/guide/bgnet/ ) for learning the BSD socket API (which is also very relevant if you decide to use SFML instead). I haven't really played around with Boost.asio... every time I download it I end up getting put off by Boosts' heavyweight nature in general...

I don't think any utility library justifies a several hundred MB download to be frank.
_______

Keep in mind that this guide does not teach networking theory! It's just a glorified API tutorial. You'll have to learn that elsewhere. Honestly I found gamedev.net to be the best place to learn, but that's just me.
Last edited on
Note how I said "BSD sockets."

Winsock isn't based off of POSIX sockets. It's based off of BSD sockets which are not technically part of the POSIX specification. I don't think you understand the difference between the two, which is a problem.

im well aware of what you said. i never said winsock is based off of posix sockets. yes its based of BSD sockets, but its not BSD sockets otherwise they would just be called BSD sockets ;). you are assuming a lot of things about my words which is a problem.

Also, even if they were based off of POSIX sockets, why would they have to adopt the POSIX standard? Windows' way of doing things is it's own standard. It's large enough that it really doesn't matter what standard that they use and what they don't.

still not sure where you think i said winsock is based off posix... im also not sure where you think i said windows would have to adopt the POSIX standard. it can just use posix sockets. like linux. its not fully posix compliant either, so please tell me where i said windows must be.

Winsock's sole purpose of creation was to be a Windows implementation of BSD sockets. It was meant to attract *nix developers to Windows. It was created with a large amount of compatibility in mind.

lolwut? who told you that? have you even read the book on the creation of winsock? from it, the author (who was one of the central players in the standardization of winsock) clearly states that it was created so it has a central networking model, instead of everyone using their own (as had been happening). it was not created to attract *nix devs. any attraction *nix devs have is coincidental.

POSIX sockets are literally just BSD sockets with a few slight alterations, meant to standardize sockets on POSIX-compatible systems.

yes. where did i say otherwise?

No it's not a light layer over BSD sockets. It's a POSIX system's way of implementing them (well not technically. POSIX sockets are really a completely different API that was based off of BSD sockets, but for all intents and purposes they're the same).

yes it is a light layer over BSD Sockets. i never said the api was the same. please stop assuming things about my post.

And now that I think of it... Linux uses POSIX features, yet it isn't technically POSIX system. Why is this? By your logic, since it supports POSIX features, it should be 100% compliant with POSIX itself!

as i said, Linux IS NOT Posix compliant. You are starting to piss me off now, though. stop fucking around and assuming things about my post, because it makes you look like a moronic ass. either point out these things in my post or stop commenting on things you are only pretending to know about.
Little Bobby Tales wrote:
im well aware of what you said. i never said winsock is based off of posix sockets.
You certainly implied it.

yes its based of BSD sockets, but its not BSD sockets otherwise they would just be called BSD sockets ;)
When did I say that they were BSD sockets?

still not sure where you think i said winsock is based off posix... im also not sure where you think i said windows would have to adopt the POSIX standard. it can just use posix sockets. like linux. its not fully posix compliant either, so please tell me where i said windows must be.
I got the impression here:
they literally arent, actually, otherwise windows would completely drop the winapi and pick up posix


yes it is a light layer over BSD Sockets.
No, it's not a layer over BSD sockets.
http://en.wikipedia.org/wiki/Berkeley_sockets

Who told you that?


POSIX sockets are literally just BSD sockets with a few slight alterations, meant to standardize sockets on POSIX-compatible systems.
yes. where did i say otherwise?
Right here:
those are posix sockets (iirc. its some sort of standard). that *is* a light layer over BSD sockets
Layer != modification

It's like saying SFML is just OpenGL with a few changes.

as i said, Linux IS NOT Posix compliant.
First off, I never said that you said that. You clearly stated* that Winsock and POSIX sockets are not similar, and that if they were, they'd be POSIX sockets.

*:
They're literally almost identical to the Unices

they literally arent, actually, otherwise windows would completely drop the winapi and pick up posix


What I said afterwards was just me attacking your logic.

You are starting to piss me off now, though. stop fucking around and assuming things about my post, because it makes you look like a moronic ass.
If your post was more clearly worded I wouldn't have to make any assumptions. Also, in several cases, it was blatantly wrong.

either point out these things in my post or stop commenting on things you are only pretending to know about.
If anyone didn't know about what they're talking about, it'd be you, considering all this information is literally just several clicks away.

Throwing insults without reason, along with getting angry because someone pointed out your misinformation makes you look like "a moronic ass."
Last edited on
@Avilius: It's not about the functional behavior. What I meant was, the function for switching a socket to async mode are named differently in windows.
Winsock has the same function used on linux, but it does not have the right flag (the function is very basilar and only emulates part of the original linux function, the involved enum is not defined).
They have a completely different function for that.
I do not remember their complete names tho.

Sorry for skipping the rest of the posts; tldr.
im well aware of what you said. i never said winsock is based off of posix sockets.
You certainly implied it.

im done with you. it is clear you are trolling.
What happened to this thread? Where did we as a community go wrong?
What happened to this thread? Where did we as a community go wrong?

ive been saying that since the whole phoenix scandal. its really gone down hill since when i first joined :/. ill probably leave soon again :p
At least I learned some stuff about posix and bsd :p
Oh, the phoenix thing. I had honestly completely forgotten about it. Mostly because phoenix barely registered as a blip and I was mostly sad about cq leaving.

Maybe we overestimated the kindness of this community. We were nice, but we were also quite tolerant of chronic asshattery. I know communities tend to degrade as they grow, but...

I am totally contributing to the derailing this thread. So sorry. I'll shut up now.

-Albatross
I actually learned quite a bit from this thread so thank you everyone who commented(even if you argued a lot)
Topic archived. No new replies allowed.
Pages: 12