Click here to Skip to main content
15,860,972 members
Articles / Desktop Programming / MFC
Article

Hello world application for socket programming in windows

Rate me:
Please Sign up or sign in to vote.
1.42/5 (12 votes)
20 Oct 20071 min read 58K   2.8K   13   8
Application for newbies in the world of

Introduction

This snippest is for every one who are just newbie in the world of network / socket programming.

I do no find any ready-made resourses that describe socket programming in simplest level thats why i made this VC++ console based application to demo all of newbie.

Background

  • Newbie should have basic of C/C++ programming
  • MSVC++ environment as i made this code in MSVC++ 2003

Using the code

As you can see this overall application devide into two part client and server.

Generally server are in listening mode, accept connection and it can recv / send data from client.

Client just connect with server and send / recv data from there.

As Demo, i have made application in which client just connect with server and after server accept connection client send data to server and server recv that data and display on screen.

Also, no you can see in client i have used loop back IP address defined 127.0.0.1 means you can test directly thos client and server on single machine, If you want to test it in different machine than change it appropriately.

To test the application you need to run first Server exe after just run Client exe and enter some data by default i have take max length of data at time is 10 byte so enter up to 10 byte and just press enter you can see that data are recv on server screen.

Screenshot - demo.jpg

Points of Interest

You can enhance this application to make it two way means both can recv and send data,

also you can port this application to dialog based and can make you own chating tool,

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionTwo way communication Pin
vimalmathew126-Jul-12 9:38
vimalmathew126-Jul-12 9:38 
Generalsocket error Pin
sheran aus17-Jun-11 20:21
sheran aus17-Jun-11 20:21 
GeneralMy vote of 5 Pin
rp_suman29-Apr-11 2:14
rp_suman29-Apr-11 2:14 
GeneralMy vote of 4 Pin
Murali 315-Apr-11 1:28
Murali 315-Apr-11 1:28 
GeneralClient-Server application modification could not e achived Pin
Yogesh Ithape27-Oct-09 0:57
Yogesh Ithape27-Oct-09 0:57 
GeneralHi iam not able to get Output Pin
thukaram.vh5-Oct-09 0:26
thukaram.vh5-Oct-09 0:26 
GeneralDon't upload build garbage! Pin
KevinSW2-Oct-08 22:52
KevinSW2-Oct-08 22:52 
Generaltest Pin
yctsai21-Oct-07 16:27
yctsai21-Oct-07 16:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.