Hello, I'm pretty much a beginner too. However, I've been using CSockets for several months now so maybe I can help.
Are you creating a Client and a server or just one?
In the simplest Client Server model, you must use 3 instances of CSocket. 2 of these CSockets are on the server side. The first on the server is a socket used for accepting calls, and should be created on a specific port (so clients know how to find it):
The sockAcptr listens for connection attempts, and will receive a message when it is able to accept a socket. When this happens, the sockAcptr should accept the call and attach it to the second server socket.
Now, all communication between the server and client goes through the socksrvr not the sockAcptr.
The client socket is created on a default port, you dont have to specify:
Connect to the server specifying the server IP address (can be in CString form) and the port the sockAcptr is listening on.
To send information back and forth, I always use CSocketFiles with CArchives.
Create a socketfile bound to the socket that will be sending (or receiving):
Create an archive bound to the file either for sending or receiving:
CArchive ar(&file, CArchive::store); OR CArchive ar(&file, CArchive::load);
then you can use the archive to send and receive info;
ar << sinfo;
ar >> sinfo;
Let me know if it helps or if you have anymore questions. you may want to double check MSDN to make sure i have the parameters in the right order on some methods.
I am also in need of socket programming..i want to do a program which can communicate with two systems using their IP address. and i am new to this socket programming..Could you please help me in this regard..It would be appreciated if you can send any sample program..