BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to use TUdpSocket (D7 Pro)??

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock
View previous topic :: View next topic  
Author Message
Bo Berglund
Guest





PostPosted: Mon Sep 15, 2003 12:05 pm    Post subject: How to use TUdpSocket (D7 Pro)?? Reply with quote



I must write a Delphi app that can communicate with a third party
machine that is connected to the LAN using sockets. The machine
accepts connection requests through an UDP channel and if
authenticated will by itself connect to my program using TCP. The
problem is the UDP part, I cannot get the damn thing working in
Delphi...
I have a working example in VB6 using the MS Winsock component, but
obviously I don't like to use VB.

The VB code looks like this (simplified):
To start the UDP channel:
socketUDP.Protocol = sckUDPProtocol
socketUDP.RemotePort = 19284
socketUDP.RemoteHost = "TheMachineName"
socketUDP.Bind 19284

In the socket DataArrival Event:
Dim ReceiveText As String
socketUDP.GetData ReceiveText, vbString, bytesTotal
'Do something with the ReceiveText string

To send data out:
socketUDP.SendData Message


In Delphi 7 I have tried with this on a TUdpSocket component:
To start the UDP channel:
sckUDP.RemoteHost := TheMachineName;
sckUDP.RemotePort := '19284';
sckUDP.LocalPort := '19284';
sckUDP.Open;

To receive text in the OnReceive event (not working, it is not even
fired):
procedure TfrmComm.sckUDPReceive(Sender: TObject; Buf: PAnsiChar; var
DataLen: Integer);
var
sRxData: string;
begin
SetLength(sRxData,DataLen);
sckUDP.ReceiveBuf(sRxData[1],DataLen);
Memo1.Lines.Add(sRxData);
end;

I know that the machine is sending, because as soon as I fire up the
VB6 test app it starts displaying the received messages.

What do I need to do to get data into the UDP component?
Is there a working example anywhere? As usual the Delphi help is of no
use. It even seems to have text referring to another type of socket
sometimes...

Grateful for any help!

/Bo
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Internet Winsock All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.