Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Client/Sever

Status
Not open for further replies.

fatcodeguy

Programmer
Feb 25, 2002
281
CA
Hi. I'm trying to write simple client & server programs (the client just sends a string to a port & ip, and the server just listens for connections).
How would I go about doing this? Help is much appreciated (sample code would be great !!) Thanks
 
If you're using Visual C++ and MFC then look at


and check out the simple socket example for client/server programs.

If you are using unix sockets or winsock (they're more or less the same thing!) - search the web for a PDF document called "Beej's guide to network programming" - this is about 20-30 pages long and gets straight to the point. Explains all the socket related functions but also gives you two or three examples of "simple" client and server programs.

I used the funducode example to create my first sockets with MFC under VC++. I used Beej's guide to create my first Windows client to UNIX server socket setup. If I can undertsnad these then anyone can!! :)
tellis.gif

programmer (prog'ram'er), n A hot-headed, anorak wearing, pimple-faced computer geek.
 
Thanks !! What's the difference between the Visual C++/ MFC Sockets and winsock?
 
MFC sockets are just "wrapper" classes that attempt to wrap the basic winsock/unix style socket functions (which can look pretty scary!). It is an attempt to make using sockets a lot easier and it succeeds to a great extent.
However, there is one small difference you need to know - the MFC sockets take away a slight amount of the control you have over the sockets such as time-out values on connections and so forth.

On saying this, I highly recommend trying MFC sockets first if you've never had any experience with sockets before!

The MFC socket classes are [tt]CSocket[/tt] and [tt]CAsyncSocket[/tt]

[rockband]
tellis.gif

programmer (prog'ram'er), n A hot-headed, anorak wearing, pimple-faced computer geek.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top