Sockets in (Visual) C++

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
captjack
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 50
Joined: Fri Sep 18, 2009 4:23 pm
Current Project: engine framework
Favorite Gaming Platforms: PC, XBox 360, PS3
Programming Language of Choice: C, C++
Location: Northern Virginia

Sockets in (Visual) C++

Post by captjack »

Hey everyone,

I have what seems like a really, really dumb question. I'm trying to do some socket programming in C++ using Visual Studio. Despite some online references about WinSock, none of the code I'm attempting works. I'm talking real simple stuff like binding a socket, nothing about sending/receiving, just getting the damn thing open.

I'm from a UNIX background and have done some pretty decent work using native Berkeley sockets, but this was in C and the socket library is well documented.

Do I need to write some C wrappers around anything to get sockets working in C++? There are probably some third party libs out there (boost perhaps), but I'd like to keep this as minimalist as possible without using too many outside libraries. So far the only external libraries I've included in my project are OpenGL and DirectX. Ideally I'd like to have some sort of socket class to do networking related tasks for the game protocols between client and server, and keep it as streamlined and manageable as possible.

A point in the right direction would be most helpful.

-capt jack
User avatar
Netwatcher
Chaos Rift Junior
Chaos Rift Junior
Posts: 378
Joined: Sun Jun 07, 2009 2:49 am
Current Project: The Awesome Game (Actual title)
Favorite Gaming Platforms: Cabbage, Ground beef
Programming Language of Choice: C++
Location: Rehovot, Israel

Re: Sockets in (Visual) C++

Post by Netwatcher »

I learned my WinSock from this site(well most of it, I had to look at actual code to figure out some other stuff)
http://www.madwizard.org/programming/tutorials/netcpp/

and dude, the Wizard in the pic... it's... YOU!!!! OMGOMGOMGOMGZZZZ!!!!555threethreethree
"Programmers are the Gods of their tiny worlds. They create something out of nothing. In their command-line universe, they say when it’s sunny and when it rains. And the tiny universe complies."
-Derek Powazek, http://powazek.com/posts/1655

blip.fm DJ profile - http://blip.fm/Noobay
current code project http://sourceforge.net/projects/vulcanengine/
User avatar
captjack
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 50
Joined: Fri Sep 18, 2009 4:23 pm
Current Project: engine framework
Favorite Gaming Platforms: PC, XBox 360, PS3
Programming Language of Choice: C, C++
Location: Northern Virginia

Re: Sockets in (Visual) C++

Post by captjack »

Sweet. That site looks excellent. I'll spend some time over there. Thanks for that.

My avatar is pretty cool. I can take no credit for him though. I got him from Tux Factory.
User avatar
Netwatcher
Chaos Rift Junior
Chaos Rift Junior
Posts: 378
Joined: Sun Jun 07, 2009 2:49 am
Current Project: The Awesome Game (Actual title)
Favorite Gaming Platforms: Cabbage, Ground beef
Programming Language of Choice: C++
Location: Rehovot, Israel

Re: Sockets in (Visual) C++

Post by Netwatcher »

I meant the picture of the wizard in the website itself.(the link I sent you)
:roll:
"Programmers are the Gods of their tiny worlds. They create something out of nothing. In their command-line universe, they say when it’s sunny and when it rains. And the tiny universe complies."
-Derek Powazek, http://powazek.com/posts/1655

blip.fm DJ profile - http://blip.fm/Noobay
current code project http://sourceforge.net/projects/vulcanengine/
User avatar
captjack
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 50
Joined: Fri Sep 18, 2009 4:23 pm
Current Project: engine framework
Favorite Gaming Platforms: PC, XBox 360, PS3
Programming Language of Choice: C, C++
Location: Northern Virginia

Re: Sockets in (Visual) C++

Post by captjack »

Netwatcher wrote:I meant the picture of the wizard in the website itself.(the link I sent you)
DOH! I even followed the link and saw that wiz... I must have been tired - didn't even register.

-capt jack
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: Sockets in (Visual) C++

Post by MarauderIIC »

When I used Beej's Guide, I didn't have any real problem following the tuts. Someone's mentioned something about "not winsock2" since then.
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
Post Reply