Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Nov : Re: TidUDPServer

www.cryer.info
Managed Newsgroup Archive

Re: TidUDPServer

Subject:Re: TidUDPServer
Posted by:"Marion Smith" (msmi..@extremeprogrammers.com)
Date:Tue, 4 Dec 2007 13:20:32

I am having the same problem as discribed in this thread. The solution
appears to be to run the app outside of the IDE. This doesn't seem like a
solution since the error is still occuring. I think Indy may have something
to address with this. I am attaching all of my code (as it is a simple
chat). When the window is closed in the IDE you should get a Socket Error #
10004.

unit MainForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Sockets, ExtCtrls, IdSocketHandle, IdBaseComponent,
  IdComponent, IdUDPBase, IdUDPServer, IdGlobal;

type
  TfrmMain = class(TForm)
    memMessages: TMemo;
    txtSend: TEdit;
    btnSend: TButton;
    udp: TIdUDPServer;
    procedure udpUDPRead(Sender: TObject; AData: TBytes;
      ABinding: TIdSocketHandle);
    procedure btnSendClick(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmMain: TfrmMain;

implementation

{$R *.dfm}

procedure TfrmMain.btnSendClick(Sender: TObject);
begin
  if txtSend.Text <> '' then udp.Broadcast(txtSend.Text, udp.DefaultPort);
  txtSend.Text := '';
end;

procedure TfrmMain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  udp.Active := False;
end;

procedure TfrmMain.udpUDPRead(Sender: TObject; AData: TBytes;
  ABinding: TIdSocketHandle);
var
  s: String;
begin
  s := BytesToString(AData);
  memMessages.Lines.Add(s);
end;

end.


"GannTrader" <Gann_Trader@hotmail.com> wrote in message
news:472cf7cf@newsgroups.borland.com...
> Hi
>
>> The only time you would ever see it is if you are running your project
>> inside the IDE's debugger.
>
> OK thats why.
> Yes i was running the project inside delphi.
> When just running the exe-file the error didn't occur.
>
> Thanx

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive