// JP opened flex table

Click to See Complete Forum and Search --> : p2p chat - accept and recv problem


beelze
February 20th, 2004, 08:17 AM
I'm making a simple chat for two users with graphical interface. I've got a problem with implementing accept function and recv.

So I've created a socket, binded it and set to listen. When I write

ClientServ = accept(srv, NULL, NULL);

the program waits for connection and does nothing besides this.

I want the program to accept the connection and work normally until it appears (receiving user's commands, etc).

The same problem I have while calling recv() function - the program stops to respond to user. Shall I use some other functions?

duch
August 4th, 2004, 06:05 PM
U can use threads or asynchronous functions

Andreas Masur
August 5th, 2004, 04:42 AM
[ Moved thread ]

Mathew Joy
August 5th, 2004, 05:11 AM
Well, this is not a problem. Both accept() and recv() work synchronously, or in other words it block till something is received (connection in the case of accept or data in the latter case). The easiest way to work around it is to use threads. You can keep on accepting in one thread and spawn a thread to exclusively handle the connection. However the best way to design depends on nature and the structure of the application as well as the connections/load to handle.

kuphryn
August 5th, 2004, 12:55 PM
What are you using to test the chat server?

Kuphryn

//JP added flex table