Doug Hale wrote:
> The problem I am having is that TidUDPClient does not seem to work from a
> console app.
> Can anyone tell me why?
Well, the program certainly seems more complicated than it needs to be,
starting with the data module and the antifreeze. TIdAntiFreeze is to
allow you to put Indy controls on a form and call their methods from your
UI thread without locking up the UI from Indy's blocking calls. You have a
console program that will have no UI at all, so there's no danger of
locking it up.
Take the body of your Run function and put it in your DPR file:
program Std2Udp;
uses SysUtils, IdUDPClient;
var
udp: TIdUdpClient;
line: string;
begin
udp := TIdUdpClient.Create(nil);
try
// Set udp properties here
while not Eof do begin
ReadLn(line);
udp.Send(line);
end;
finally
udp.Free;
end;
end.
> uses
> SysUtils,
> Unit1 in 'Unit1.pas' {stdinToUDP: TDataModule};
>
> begin
> stdinToUDP.Run;
> end.
You're calling a method on a variable that does not refer to a valid
object instance.
Beyond that, you need to be more specific about what you mean when you say
your program "does not seem to work."
Keep in mind that UDP makes absolutely no guarantee that anything it sends
will ever arrive anywhere. That's TCP's job.
--
Rob