Computing.Net > Forums > Programming > CScokets problem in C++

CScokets problem in C++

Reply to Message Icon

Original Message
Name: jeff80000
Date: November 25, 2005 at 06:14:51 Pacific
Subject: CScokets problem in C++
OS: WinXP
CPU/Ram: 1g, 3 GHz
Comment:

Im writing an application in C++ MFC that involves the CSocket class. My program works fine but when I use the CSocket::Accept function the program hangs untill it has received a connection from the client.

Heres basically how my code is written:

CSocket socketSvr;
CSocket client;
socketSvr.Create(2000); //Create the socket
socketSvr.Listen(1); //Listen for connections
socketSvr.Accept(client); //Accept a connection

It is at this point while waiting for the client to connect that the program hangs. This is because the Accept function will not return untill the client has connected. Is there another way to get the Accept function to return? Am I doing something wrong?

Thnaks


Report Offensive Message For Removal

Response Number 1
Name: Chi Happens
Date: November 29, 2005 at 10:04:37 Pacific
Subject: CScokets problem in C++
Reply: (edit)

There should be an event for the CSocket class that lets you know that a client is attempting to connect. You should put your Accept code in there.

Chi

They mostly come at night...mostly.


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: CScokets problem in C++

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software