🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #2367

Re: TIdUDPServer (and Client)

#2367
From: Remy Lebeau (TeamB)
Date: Sun, 28 May 2006 19:35
34 lines
2174 bytes
"Paul" <plmacca@clara.co.uk> wrote in message
news:44796d7e$1@newsgroups.borland.com...

> I have got the client sending data to the server, and this seems ok (the
> server event handler, and client thread extract is below).  What I don't
> understand or know how to achieve is the client receiving data back
> from the server.  I've not managed to get this to work so far.

In the server's OnUDPRead event, you are provided with the IP and port of
the client.  Send your data to that IP/port.

> can the server only respond in read event handler using the socket
> binding information to know where to return the data?

Exactly.

> I've also noticed that when the server sends data, it receives its own
data
> (when using 127.0.0.1 addresses for both ends).

UDP data can appear on any network adapter that is installed.  Depending on
how you are sending the data and where, it is possible for the server to
receive its own data back.  It is your responsibility to look at the data
and ignore anything you don't want.

> if I want two PCs to communicate async, do I need both
> ends to be server and clients?

No.  The server is already asynchronous.  On the client side, simply use the
UDPClient in a thread so the main thread is not blocked.


Gambit
Technical Details
Message-ID: <4479fd0f$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <44796d7e$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,826a7ca2cbe06100
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <44796d7e$1@newsgroups.borland.com>
Subject: Re: TIdUDPServer (and Client)
Date: Sun, 28 May 2006 12:35:41 -0700
Lines: 36
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.69.17.41
Message-ID: <4479fd0f$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1148845327 68.69.17.41 (28 May 2006 12:42:07 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail