Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Indy UDP server: 10004, when stopping threaded app

431 views
Skip to first unread message

Stefan Paege

unread,
May 9, 2001, 6:08:46 AM5/9/01
to
Hi,

I try to use a TIdUDPServer component in a workerthread of my app. All is
fine (data is received) until I close the app. I then get an exception of
class EIdSocketError. Message: 'Socket Error # 10004 Interrupted system
call'.

Call stack:
TIdThread.Execute
TIdUDPListener.Run
TIdStack.CheckForSocketError(-1)
TIdStack.CheckForSocketError(-1, (...))
TIdStack.RaiseSocketError(10004)


The exception only comes up when the app is run in the debugger, otherwise
it is swallowed. Should I ignore this behaviour or is there a problem?
BTW: I did read the paragraph about error 10038 during shutdown, but this is
10004, so I will not get tarred and feathered (I hope)...

Here is the relevant code of my workerthread:

{ TUdpThread }

procedure TUdpThread.Init(Port: Integer); // Is called after thread creation
before resuming the thread
begin
New(UdpContainer);
New(UdpHeaderRec);
UdpRcv := TIdUdpServer.Create(nil); // This is our receiver
UdpRcv.DefaultPort := Port;
end;

procedure TUdpThread.Execute;
var
RcvSize: Integer;
begin
UdpRcv.Active := True; // Activate receiver
while not Terminated do begin
if Assigned(UdpRcv) and UdpRcv.Active then begin
RcvSize := UdpRcv.ReceiveBuffer(UdpContainer^[SizeOf(TUdpHeaderRec)],

UdpContainerSize-SizeOf(TUdpHeaderRec), 200);
if (RcvSize > 0) and (RcvSize < UdpContainerSize-RcvSize) then begin
UdpHeaderRec^.Size := RcvSize;
Move(UdpHeaderRec^, UdpContainer^, SizeOf(TUdpHeaderRec));
if FBuf.BlockingWrite(UdpContainer) then
New(UdpContainer);
end;
end;
end;
end;

destructor TUdpThread.Destroy;
begin
FreeAndNil(UdpRcv); // Exception is raised when executing this line
FreeMem(UdpContainer);
Dispose(UdpHeaderRec);
inherited;
end;

Here is my main form's Destroy method:

procedure TMyFrm.FormDestroy(Sender: TObject);
begin
UdpThread.Terminate;
UdpBuf.ResetState;
UdpThread.WaitFor;
UdpBuf.Free;
UdpThread.Free;
end;


Kudzu - Team Indy

unread,
May 9, 2001, 8:38:21 AM5/9/01
to
pa...@el-carls.de (Stefan Paege) wrote in <3af9172f_1@dnews>:

>The exception only comes up when the app is run in the debugger, otherwise
>it is swallowed. Should I ignore this behaviour or is there a problem?

Yes. As designed.

>BTW: I did read the paragraph about error 10038 during shutdown, but this is
>10004, so I will not get tarred and feathered (I hope)...

10038 is the most common, but MS keeps changing the error that gets returned
with each OS. Which OS are you running?

--
Chad Z. Hower (Kudzu) - Church Hill, TN - Team Indy
"Programming is an art form that fights back"
Forget the Y2K problem, Lets fix the W2K problem.
http://www.pbe.com/Kudzu/ - Free Delphi/CBuilder components and articles

Stefan Paege

unread,
May 9, 2001, 8:54:00 AM5/9/01
to

"Kudzu - Team Indy" <cha...@pbe.com> schrieb im Newsbeitrag
news:909C5D2BCc...@207.105.83.65...

> pa...@el-carls.de (Stefan Paege) wrote in <3af9172f_1@dnews>:
> >The exception only comes up when the app is run in the debugger,
otherwise
> >it is swallowed. Should I ignore this behaviour or is there a problem?
>
> Yes. As designed.

OK, fine.

>
> >BTW: I did read the paragraph about error 10038 during shutdown, but this
is
> >10004, so I will not get tarred and feathered (I hope)...
>
> 10038 is the most common, but MS keeps changing the error that gets
returned
> with each OS. Which OS are you running?

This is on W2K SP1

Thanks Chad

Stefan


0 new messages