Thread View: borland.public.cppbuilder.internet.socket
8 messages
8 total messages
Started by Kresten Tolstrup
Tue, 27 Mar 2007 13:46
UDP socket
Author: Kresten Tolstrup
Date: Tue, 27 Mar 2007 13:46
Date: Tue, 27 Mar 2007 13:46
7 lines
1216 bytes
1216 bytes
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
Re: UDP socket
Author: 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
Re: UDP socket
Author: Paul at NCF
Date: Thu, 29 Mar 2007 21:48
Date: Thu, 29 Mar 2007 21:48
26 lines
1818 bytes
1818 bytes
Hi, I've not used this component, but I have used the Indy UDP components. Indy has separate Client and Server components, whereas this borland component seems to be doing both functions, which seems strange and with no obvious settings for setting it up for either. I had a quick play with it but not found out much so far. Paul "Kresten Tolstrup" <kt@danphone.com> wrote in message news:4609120b$1@newsgroups.borland.com... > > 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
Re: UDP socket
Author: Remy Lebeau (TeamB)
Date: Thu, 29 Mar 2007 23:15
Date: Thu, 29 Mar 2007 23:15
30 lines
1809 bytes
1809 bytes
"Kresten Tolstrup" <kt@danphone.com> wrote in message
news:4609120b$1@newsgroups.borland.com...
> Does anyone have a simple example, that shows how
> to use TUdpSocket. I use C++ builder 6.0.
Borland's socket components for CLX are horribly written. I strongly
advise you to not use them at all. There are plenty of third-party
components that are much better.
> When I try to send anything I receive errorcode 10038.
WSAENOTSOCK (10038)
Socket operation on non-socket.
An operation was attempted on something that is not a socket.
Either the socket handle parameter did not reference a valid socket,
or for select, a member of an fd_set was not valid.
> 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.
You have to specify the Host before you call Open() or Connect(). You
can't set it afterwards.
Gambit
Re: UDP socket
Author: Kresten Tolstrup
Date: Tue, 10 Apr 2007 10:23
Date: Tue, 10 Apr 2007 10:23
23 lines
1698 bytes
1698 bytes
Hi, I have now used the Indy components, and it is working, but isn't there any callback function in the client class, like the IdUDPServerUDPRead function in the server class, or do I have to poll the client class to see if it has received anything? Best Regards Kresten "Paul at NCF" <notplmacca@clara.co.uk> wrote: >Hi, > >I've not used this component, but I have used the Indy UDP components. Indy >has separate Client and Server components, whereas this borland component >seems to be doing both functions, which seems strange and with no obvious >Paul > > >"Kresten Tolstrup" <kt@danphone.com> wrote in message >news:4609120b$1@newsgroups.borland.com... >> >> Hello >> >> Does anyone have a simple example, that shows how to use TUdpSocket. I use
Re: UDP socket
Author: Remy Lebeau (TeamB)
Date: Tue, 10 Apr 2007 17:02
Date: Tue, 10 Apr 2007 17:02
24 lines
1942 bytes
1942 bytes
"Kresten Tolstrup" <kt@danphone.com> wrote in message news:461b577e$1@newsgroups.borland.com... > I have now used the Indy components, and it is working, but > isn't there any callback function in the client class, like the > IdUDPServerUDPRead function in the server class No, there is not. But you can use TIdUDPServer for both a client and a server, as it has all of the same writing methods that TIdUDPClient has. The only difference between TIdUDPClient and TIdUDPServer is that the former exposes Host and Port properties, which you don't really need, and the latter allows listening on multiple local IP/Port pairs, which you only need 1 of on the client side. Otherwise, they are both the same, as they both derive from TIdUDPBase, which implements most of the work equally between them. > do I have to poll the client class to see if it has received anything? Yes, you would. Gambit
Re: UDP socket
Author: Kresten Tolstrup
Date: Thu, 12 Apr 2007 11:04
Date: Thu, 12 Apr 2007 11:04
34 lines
2153 bytes
2153 bytes
Hi OK, I use the server as client to, the event OnUDPRead is then called when a UDP packet is received, and I can get the data from the Tstream, but how can I get the size, if I use the function AData->GetSize(), then I get the error "not accessible". Kresten "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> wrote: > >"Kresten Tolstrup" <kt@danphone.com> wrote in message >news:461b577e$1@newsgroups.borland.com... > >> I have now used the Indy components, and it is working, but >> isn't there any callback function in the client class, like the >> IdUDPServerUDPRead function in the server class > >No, there is not. But you can use TIdUDPServer for both a client and >a server, as it has all of the same writing methods that TIdUDPClient >has. The only difference between TIdUDPClient and TIdUDPServer is >that the former exposes Host and Port properties, which you don't >really need, and the latter allows listening on multiple local IP/Port >pairs, which you only need 1 of on the client side. Otherwise, they >are both the same, as they both derive from TIdUDPBase, which >implements most of the work equally between them. > >> do I have to poll the client class to see if it has received >anything? > >Yes, you would. > > >Gambit > >
Re: UDP socket
Author: Remy Lebeau (TeamB)
Date: Thu, 12 Apr 2007 17:13
Date: Thu, 12 Apr 2007 17:13
12 lines
1358 bytes
1358 bytes
"Kresten Tolstrup" <kt@danphone.com> wrote in message news:461e0413$1@newsgroups.borland.com... > how can I get the size, if I use the function AData->GetSize(), > then I get the error "not accessible". Use the public Size property instead. GetSize() is the getter method for the property. Gambit
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads