Click to See Complete Forum and Search --> : Single Server Multiple Clients


hkullana
July 3rd, 2007, 10:21 AM
hi,

i am doing a big windows programming project. In the initialization state the program should connect to a server and asks for permission to start. Asking for permission is made by sending and receiving data(floating license). For example:

Program starts.
Connect to server.
Send a message to server ("hello")
Receive a message from server ("hello")
Send a message to server ("can i run?")
Receive a message from server ("yea") // these are done automatically in every start.

In the network each computer that runs my product show connect to server and send receive message. The problem is:

When i implement simple socket programming it does not provide multiple clients. I need a server/client application that supports multiple clients.

I am not good at socket programming and i have to work more on the rest of the project; so, i am looking an implementation, lib, class ...etc. to do what i want easily. (this is an mfc project/server can be console application).

thanks for help

dog_pig_baby
July 3rd, 2007, 11:48 PM
use ACE

henky@nok.co.id
July 10th, 2007, 02:02 AM
You can use multithreading technique to handle connected socket.
By passing accepted socket to new thread, you still can handle
listening socket. The other way is using multi process (using fork()
function).

yoni1993
July 22nd, 2007, 06:47 PM
if i do what henky said, then if "nthread" is the new thread that handle a connection from a client, do the nthread have all function like socket, i mean if i can do that for example ?

nthread.send(xxxxxxxx);

tnx

keenlearner
July 27th, 2007, 05:14 PM
You might one to consider the IO completion port of Winsock strategy, it's the most efficient IO strategy that I have seen so far, it can receive many clients connection and perform IO operations concurrently. This link will be good for you to start http://www.codeproject.com/internet/SimpleIOCPApp.asp

MikeAThon
July 27th, 2007, 07:32 PM
The OP is writing a client, whereas the article you gave him is for a server.

Incidentally, the article provides a file named clientIOCP.zip, and describes the file as follows:
ClientIOCP.zip contains the IOCP client; the IOCP client can stress-test the IOCP server.
It sounds like a client using IOCP, but in fact the code most decidedly does not use IOCP. Rather, it is a simple multi-threaded client using standard BSD socket calls.

Mike

keenlearner
July 28th, 2007, 03:35 AM
I need a server/client application that supports multiple clients.

He needs to support multiple clients, so I assume that he like to built the server application. Even if it's a client application, after reading the link and understand how IOCP work, we will be able to apply ourselves for client as well.

Hello, MikeAThon, since you said that it does not applied IOCP on the client, what will be the benefit of IOCP on client, is it one client able to connect to multiple server ? It will be interesting if you would tell me what other benefits, because most IOCP code that I saw always deal with the server. Thank you.

PS : I just tried to help as maximum with as maximum knowledge that I have learnt so far, sorry if I am wrong.

MikeAThon
July 31st, 2007, 11:21 AM
As you yourself learned here, "WSAAsyncSelect with IOCP for client ", http://www.codeguru.com/forum/showthread.php?t=427541 , reliance on that article alone will not teach you how to use IOCP for a client. You also need to know about the ConnectEx() function.

As for advantages in a client, IOCP in a client provides the same advantages as in a server, namely, highly efficient processing for a large number of simultaneous connections. The reason that you do not find sample code for a client is that the client rarely needs those advantages, whereas most servers do. There are only a few cases where the client needs those advantages, and one is the web scaping robot that you and the OP are building, which explains why it's rare to find any IOCP code for a client.

Mike