Article View: borland.public.cppbuilder.internet.socket
Article #85Can a TIdUDPClient "listen" on a local port?
From: jesse
Date: Thu, 24 Apr 2008 19:25
Date: Thu, 24 Apr 2008 19:25
43 lines
2372 bytes
2372 bytes
I've been trying to set up a UDP communication where the communication
is "one way." I assumed I could use TIdUDPClients for both ends. I
was not able to get this working because I couldn't find a way to get
a TIdUDPClient to listen on a local port.
Is it possible to get TIdUDPClient to "listen" on a local port on the
receiving side of the communication?
Here is the "server" side sample code:
__fastcall InputThread::InputThread(bool CreateSuspended, char*
ipAddress, int portNumber)
: TThread(CreateSuspended)
{
udpClient = new TIdUDPClient(NULL);
this->ipAddress = ipAddress;
this->portNumber = portNumber;
udpClient->Active = true;
}
void __fastcall InputThread::Execute()
{
TIdBytes buffer;
int count, portNumber;
AnsiString ipAddress;
while(!Terminated) {
udpClient->ReceiveBuffer(buffer, ipAddress, portNumber,
IdTimeoutInfinite);
if(ipAddress.ToInt() != this->ipAddress)
continue;
for(int i=0; i < cont; ++i) {
outFile << buffer[i];
}
}
if(outFile.is_open())
outFile.close();
udpClient->Active = false;
}
The "client" side of the code is working, I am capturing the packets
with wireshark.
Jesse
Technical Details
Message-ID:
<8c25e27d-8591-473a-8149-de7dfa535aae@m3g2000hsc.googlegroups.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!m3g2000hsc.googlegroups.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 11508e,de53d11d394597e,start X-Google-Attributes: gid11508e,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: arc1-ca.pugleaf.net!g2news1.google.com!postnews.google.com!m3g2000hsc.googlegroups.com!not-for-mail From: jesse <jesse@goerz.us> Newsgroups: borland.public.cppbuilder.internet.socket Subject: Can a TIdUDPClient "listen" on a local port? Date: Thu, 24 Apr 2008 12:25:16 -0700 (PDT) Organization: http://groups.google.com Lines: 44 Message-ID: <8c25e27d-8591-473a-8149-de7dfa535aae@m3g2000hsc.googlegroups.com> NNTP-Posting-Host: 128.217.77.226 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1209065117 11529 127.0.0.1 (24 Apr 2008 19:25:17 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 24 Apr 2008 19:25:17 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: m3g2000hsc.googlegroups.com; posting-host=128.217.77.226; posting-account=6q83zQoAAABx03s3-G4Ic6LwTjCEzh3b User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14,gzip(gfe),gzip(gfe)