Article View: borland.public.cppbuilder.internet.socket
Article #5242TUdpSocket: Possible to receive data?
From: SEA
Date: Mon, 27 Sep 2004 14:17
Date: Mon, 27 Sep 2004 14:17
72 lines
3403 bytes
3403 bytes
Hello group,
I have a UDP problem that is almost driving me crazy. ANY hints will be
very much appreciated!
I'm trying to set up a simple test program that receives data on a UDP port,
but I can't get it to work. The VCL component is UdpSocket from the
Internet tab (BCB 6.0 Pro).
The problem is that I can't seem to receive any data, no matter what I try.
From my previous experiences with sockets, I would assume that it should be
enough to do the following steps:
1. Add a UdpSocket to the form
2. Add hander for OnReceive event
3. Set udp->LocalPort = PortNumber that I will be listening on (6666 in my
case)
(at either runtime or design time)
4. Set udp->RemoteHost = Address of machine that is allowed to connect to me
(have tried localhost and 127.0.0.1 . Is there a "wildcard" like
INADDR_ANY?)
5. Do udp->Open() (or set active = true at design time)
When I do "netstat" from a console window, I see that my application process
does
indeed have an active connection:
>netstat -a -p UDP -o
Active Connections
Proto Local Address Foreign Address State PID
...
UDP NOD2155:1555 *:* 1444
...
The problem is that the port number does not correspond with the one I
specified (6666)
Also, trying to send data to port 6666 and 1555 (in this case) fails
(nothing comes through).
The sending application has been verified earlier.
Next step was to add a toggle button that does udp->Open/Close. For each
time I do Open
there is a new entry in netstat, with port number increased by 1. The
previous ports are still
in the netstat list, and they remain there until I terminate the
application.
>netstat -a -p UDP -o
Active Connections
Proto Local Address Foreign Address State PID
...
UDP NOD2155:1555 *:* 1444
UDP NOD2155:1556 *:* 1444
UDP NOD2155:1557 *:* 1444
UDP NOD2155:1558 *:* 1444
UDP NOD2155:1559 *:* 1444
UDP NOD2155:1560 *:* 1444
...
Any idea about what I'm doing wrong, and how do get it right?
Thanks in advance!
S.E.
PS! I also had a brief look at Fastnet->NMUDP and Indy Servers->IdUDPServer,
but for various reasons I would prefer to use UdpServer if possible.
Technical Details
Message-ID:
<41582101@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!in.100proofnews.com!in.100proofnews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 11508e,1b5e2169549d9402,start X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "SEA" <sea_mail001@broadpark.no> Newsgroups: borland.public.cppbuilder.internet.socket Subject: TUdpSocket: Possible to receive data? Date: Mon, 27 Sep 2004 16:17:24 +0200 Lines: 74 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.3790.181 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.181 NNTP-Posting-Host: 80.239.27.101 Message-ID: <41582101@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1096294657 80.239.27.101 (27 Sep 2004 07:17:37 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!in.100proofnews.com!in.100proofnews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail