Original Post
I''m using MFC''s CAsyncSocket, overriding the virtual members. For right now I just want to run two programs simultaneously on my computer, one sends a message and the other receives it (of course I am DIALED UP, so the message should travel to and back from my connection host). I get a funny error when I try to connect to the listening socket that says something like "an operation was attempted on something that isn''t a socket".
This is the class:
class MySock : public CAsyncSocket
{
public:
MySock *server; //socket that is used to accept
HWND h;
void OnAccept();
void OnConnect();
void OnSend();
void OnReceive();
};
void MySock::OnConnect() //client
{
MessageBox(h,"Connected",NULL,MB_OK);
}
void MySock::OnAccept() //server, creates server socket
{
server = new MySock();
Accept(*server);
server->h = h;
MessageBox(h,"Accepted connection",NULL,MB_OK);
}
void MySock::OnReceive()
{
char msg[100];
Receive(msg,100);
MessageBox(h,msg,NULL,MB_OK);
}
void MySock::OnSend()
{
Send("hahahahahahahahah",10);
}
Then I create a socket in both programs, one calls MySock::Listen() and the other calls MySock::Connect(), specifying the same IP address I used to create the server socket and its current port. I''ve checked all other points and the error occurs only in MySock::Connect() call. I can''t figure it out.
Thanks for any help,
Alex.