C++ Socket Programming

phokur

n00b
Joined
Sep 3, 2007
Messages
44
I can't find a good answer anywhere. I am in a networking class and the prof told us to make a instant messenger. I am supposed to write the client. I decided it was a good excuse to learn c++ so I got Visual Studio 2005 and learned the basics from a couple books. I also know Java but am about two years out of practice.

So can anybody point me in the right direction? My textbook stays surprisingly vague on socket programming.

edit: having read the sticky I want you all to know I am not asking for anybody to do the assignment for me. Just for a website to help me understand the basics of socket programming with C++. I am confident I can finish it from there.
 
Well, C/C++ themselves do not directly support socket programming with any built in language features, though there are APIs that are operating systems dependent that assist you in socket programming. Examples include BSD sockets API or Winsock API (based on BSD API).

When I did networks programming I used the book Unix Network Programming volume 1, but that is geared towards Unix/Linux-type systems.

I also referenced this site a few times, it is a tutorial on BSD API programming with C/C++ code.
http://www.beej.us/guide/bgnet/

I am not as familiar with Winsock programming, you might want to look on msdn.com
 
Thanks for the reply! I'm not going to be using unix/linux, so I guess I'll start looking into Winsock. Thanks again :D
 
MSDN isn't that bad for information about the win32 api calls for things.

For the winsock calls, i would start here: Getting Started with Winsock

The "simple" sample app it references in the SDK should be worth looking at as well.

C++ doesnt really do a whole lot by itself, you need to know the api's that your operating systems expose. For visual studio, its the win32 api.
 
Beej's guide is a good resource, even if it's not in your language. The synatx may change a bit & some OO languages will wrap socket in objects but, at the ocre, pretty much everyone still follows the BSD semantics.

If you're able to work on a closed network (IE - no firewalls & direct access to clients involved) you might find that working with Java's RMI the easiest way to handle client/servier communication. When it works, it basically lets the server call methods on clients when something happens. In many real world situations it's not worth using, but in a controlled environment (like a computer lab) it's often the easiest solution
 
As a programmer, I have to aggree with the last guy and what i've read. Dont use C++ for this because if you do not understand it, you will hate life man. Im still getting my degree from my university but I'd suggest java because I believe quite a few of the online web messengers using it as a auxilleray (drunkness sux). Anyway, Write a simple program that just links up and displays chat between two computers, once that is installed figure out a formula on how to have on connect to the other on mouse clicks, and then you should be good. I mean I could write it but not being technical on what he wants and not getting paid is'nt my range.
 
Back
Top