• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 194
  • Last Modified:

Network Programming

I am currently working on a project that requires me to read input from TCP/IP ports using Visual C++ 6.0.  I would need to input the specific port number along with the IP address that I want to monitor.  The program will in turn monitor the port and output the data to the screen.

Since I do not have any network programming experience I am looking for all the help I can get. (Also, I do not know what library to use for this project. WinInet doesn't seem to be the right one.)
1 Solution
Dear chunfei!
what u need to use is sockets, vc++ has 2 classes for that CSocket, and CAsyncSocket, the different between them is CAsyncSocket is blocked in recieve, untill something getting in the port.

to create new socket you have to hand it the IP address u want to connect to, and the port u want to connect through
like this CSocket socket(IP,Port)

now u have a connection established.

to send through that socket use the Send function with the buffer and its size, and to recieve use Recieve, with the buffer u want to get the info into and the size u expecting to get.

like this:

char szBuffer[255];
CSocket socket("",2045);

recieve returns the exect amount of bytes recieved, u can expect 255 bytes, but you actully can get only 100 or less or more...

hope that will help.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now