Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-11

One server and several clients [lNet]

5 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

User

Hi, I have a client-server program made with lNet and I have several clients conected to the server.

The clients send petitions to the server and I want that the response for the server is only for the client that has generated the petition.

For example I have three clients and one of them send "Hello" to the server.

When the server receibe "Hello" its responds "How are you?" but I want that the server only send "How are you?" to the client whom it has sent "Hello" and not for all the clients.

Thanks.

Best regards.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20081114/631fc471/attachment.html

Reply by email

John vd Waeter
to User
ser wrote 15 lines
Hi, I have a client-server program made with lNet and I have several clients conected to the server. The clients send petitions to the server and I want that the response for the server is only for the client that has generated the petition. For example I have three clients and one of them send "Hello" to the server. When the server receibe "Hello" its responds "How are you?" but I want that the server only send "How are you?" to the client whom it has sent "Hello" and not for all the clients. Thanks. Best regards.

You probably are broadcasting (=sending to ip=0.0.0.0)? Using UDP?
When reading "Hello" you should take note of the senders ip-address and port and then send the "How are you" to that ip/port.

I think it's called something like peerport and peerip... not sure, don't have lNet at hands...

gl,
John

Reply by email

Damien Gerard
to User: Hi, I have a client-server program made with lNet and I have several clients conected to…

Le Nov 14, 2008 ? 5:42 PM, User a ?crit :

Show quoted text 13 lines
Hi, I have a client-server program made with lNet and I have several clients conected to the server. The clients send petitions to the server and I want that the response for the server is only for the client that has generated the petition. For example I have three clients and one of them send "Hello" to the server. When the server receibe "Hello" its responds "How are you?" but I want that the server only send "How are you?" to the client whom it has sent "Hello" and not for all the clients.

Each client connection has an id.
Take a glance at http://svn.freepascal.org/svn/fpcprojects/lnet/trunk/examples/console/ltcp/lserver.pp

You should use TLSocket to make the difference between each client

Damien Gerard La raison de la bouffe est toujours la meilleure.

Reply by email

Leonardo M. Ramé
to User: Hi, I have a client-server program made with lNet and I have several clients conected to…

You made the server? or you need help in programming one?

If you have a socket server already running, you should know when a client make a petition, the server knows "who" made that petition and responds to it. Not to all connected clients.

Leonardo M. Ram?
Griensu S.A. - Medical IT C?rdoba
Tel.: 0351 - 4247979

User escribi?:

Show quoted text 25 lines
Hi, I have a client-server program made with lNet and I have several clients conected to the server. The clients send petitions to the server and I want that the response for the server is only for the client that has generated the petition. For example I have three clients and one of them send "Hello" to the server. When the server receibe "Hello" its responds "How are you?" but I want that the server only send "How are you?" to the client whom it has sent "Hello" and not for all the clients. Thanks. Best regards. ------------------------------------------------------------------------ _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Aleš Katona
to User: Hi, I have a client-server program made with lNet and I have several clients conected to…
Show quoted text 16 lines
Hi, I have a client-server program made with lNet and I have several clients conected to the server. The clients send petitions to the server and I want that the response for the server is only for the client that has generated the petition. For example I have three clients and one of them send "Hello" to the server. When the server receibe "Hello" its responds "How are you?" but I want that the server only send "How are you?" to the client whom it has sent "Hello" and not for all the clients. Thanks. Best regards.

More info is required:

Are you using TCP? Then you need to sent to the given TLSocket which was used as argument to your OnReceive, something like

TCP.SendMessage('whatever', aSocket);

Are you using UDP? Then there's only one socket all the time, but you can filter the sends by IP:Port combination. Use aSocket.PeerPort and aSocket.PeerAddress to respond (or build a list of users for example, stringlist works best). Then just do:

UDP.SendMessage('whatever', peer) where "peer" is a string like:
'111.22.33.44:4665' (aSocket.PeerAddress + ':' + aSocket.PeerPort);
Ale? Katona

Reply by email