Article View: borland.public.cppbuilder.internet.socket
Article #1148Re: UDP socket
From: Kresten Tolstrup
Date: Thu, 29 Mar 2007 12:06
Date: Thu, 29 Mar 2007 12:06
35 lines
2431 bytes
2431 bytes
"Kresten Tolstrup" <kt@danphone.com> wrote:
>
>Hello
>
>Does anyone have a simple example, that shows how to use TUdpSocket. I use C++ builder 6.0. When I try to send anything I receive errorcode 10038. I setup the local and remote port numbers, then I call connect(), I have also tried with open(), after that I setup remote host and call SendBuf, then the Event UdpSocketError is called. There is not any server or client settings, is that correct?.
>
>Best Regards
>Kresten
When I setup the following:
if (bServer)
{
UdpSocket->RemoteHost = "<Any>";
UdpSocket->RemotePort = 0;
UdpSocket->LocalHost = "<Any>";
UdpSocket->LocalPort = 34100;
}
else
{
UdpSocket->RemoteHost = "192.168.0.27";
UdpSocket->RemotePort = 34100;
UdpSocket->LocalHost = "<Any>";
UdpSocket->LocalPort = 0;
}
UdpSocket->Open();
there are no errors when bServer is false, and the Event UdpSocketConnect is called.
When bServer is true the event UdpSocketError is called with socket error 10049. If I then change RemoteHost to 127.0.0.1, then UdpSocketError is not called, but if it shall work as a server, the remote host cannot be specified. So how shall it be setup to a server ?
The C Builder Developer's guide say, on page 37-7, that the LocalPort property shall be set, and nothing else. It also says that there is an OnAccept event, that is called when a client has connected, but UdpSocket don't have this event.
For client sockets it says that the remote port and remote address shall be set and nothing else.
Best Regards
Kresten
Technical Details
Message-ID:
<460b9dc8$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4609120b$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,eda79d322010114f X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Kresten Tolstrup" <kt@danphone.com> Sender: "Kresten Tolstrup" <kt@danphone.com> Reply-To: "Kresten Tolstrup" <kt@danphone.com> Subject: Re: UDP socket Newsgroups: borland.public.cppbuilder.internet.socket X-User-Info: 80.196.23.205 References: <4609120b$1@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.66 Message-ID: <460b9dc8$1@newsgroups.borland.com> Date: 29 Mar 2007 04:06:48 -0800 X-Trace: newsgroups.borland.com 1175166408 207.105.83.66 (29 Mar 2007 04:06:48 -0800) Lines: 35 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail