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 

Simple TCP

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc
View previous topic :: View next topic  
Author Message
Peter
Guest





PostPosted: Sat Feb 28, 2004 9:22 pm    Post subject: Simple TCP Reply with quote



Hi all.

I am using the Simple TCP components from Utilmind and have a small
problem with them in relation to a connection error. I cannot get any
support from the company or even a return email.

I find the components easy to use but just need this one small problem
fixed. Does anyone else use them?

I use the Broadcast Stream procedure a fair bit to send data to all
connected clients. If one of the clients disconnects uncleanly say
with a broken dial up connection, the server component doesn't see it
as disconnected and continues to try and send data to it. This results
in a message box popping up saying CONNECTION REFUSED. My app sends
data every 10 seconds so I get another of these boxes every 10 seconds
until the screen is full of them.

Would anyone be prepared to look at the source for the components as
it is supplied and trapp the error for me please? I have tried but am
still missing it and am getting desperate.

Regards, Peter
Back to top
David Reeve
Guest





PostPosted: Sun Feb 29, 2004 11:43 am    Post subject: Re: Simple TCP Reply with quote



"Peter" <google (AT) sale-net (DOT) com.au> wrote

[snip]
Quote:
Would anyone be prepared to look at the source for the components as
it is supplied and trapp the error for me please? I have tried but am
still missing it and am getting desperate.

Hmmm ....bit of spare time this evening, so download the source and a quick
look shows it to be a very tidy piece of coding. You really should be able
to find your way through it without problem. Did you try stepping it?

So.... BroadcastStream calls SendStreamTo for every connection in the
current connection list. Problem is, not all connections in the list are
valid. It might well be worth enquiring how you can keep this connection
list tidy, but if you can live with the odd duff connection, maybe it isn't
important.

So lets see what happens..... SendStreamTo calls, one way or another,
SendBufferTo which finally calls into winsock.pas and the underlying socket
layer with Send. If this Send fails, the next line retrieves the error from
the underlying socket layer and calls the generic error handler,
SocketError, with it.

In the error handler WSAECONNREFUSED is translated to 'Connection refused',
and if you haven't assigned a handler for the OnError event, an exception is
raised bearing this text. As I understand it, an exception isn't raised, but
a dialog is popped. This can only mean you must be handling the OnError
event by using something like ShowMessage(ErrorMsg). So....unless I've
missed the point, and that is a real possibility, the solution to the
problem lies in a simple change to your OnError handler. For starters, I
would never pop a dialog for the output of a communications error handler.
You can have a screen full of dialogs before you know what was happened. How
about log it to a memo?

Dave



Back to top
Peter
Guest





PostPosted: Sun Feb 29, 2004 8:15 pm    Post subject: Re: Simple TCP Reply with quote



Hi David.
Thanks for the time taken so far.
Well I have some code allocated to the ONERROR event already. My
understanding is that it doesn't have to handle specific errors but I
may be wrong. As you mentioned, I simply have the code firing a beep.
I could change it to a LOG to MEMO type function.

I haven't got it raising a diag box at all. It seems the component
does that and as you mentioned, it fills the screen in no time. Hence
thats where my problem is. I have code in the Onerror event and yet
the boxes still appear when I seem to have lost one of the clients in
the list....

Regards, Peter


"David Reeve" <dree4456 (AT) big-pond (DOT) net.au> wrote

Quote:
"Peter" <google (AT) sale-net (DOT) com.au> wrote in message
news:6a3f6a71.0402281322.1c5f75d3 (AT) posting (DOT) google.com...
[snip]
Would anyone be prepared to look at the source for the components as
it is supplied and trapp the error for me please? I have tried but am
still missing it and am getting desperate.

Hmmm ....bit of spare time this evening, so download the source and a quick
look shows it to be a very tidy piece of coding. You really should be able
to find your way through it without problem. Did you try stepping it?

So.... BroadcastStream calls SendStreamTo for every connection in the
current connection list. Problem is, not all connections in the list are
valid. It might well be worth enquiring how you can keep this connection
list tidy, but if you can live with the odd duff connection, maybe it isn't
important.

So lets see what happens..... SendStreamTo calls, one way or another,
SendBufferTo which finally calls into winsock.pas and the underlying socket
layer with Send. If this Send fails, the next line retrieves the error from
the underlying socket layer and calls the generic error handler,
SocketError, with it.

In the error handler WSAECONNREFUSED is translated to 'Connection refused',
and if you haven't assigned a handler for the OnError event, an exception is
raised bearing this text. As I understand it, an exception isn't raised, but
a dialog is popped. This can only mean you must be handling the OnError
event by using something like ShowMessage(ErrorMsg). So....unless I've
missed the point, and that is a real possibility, the solution to the
problem lies in a simple change to your OnError handler. For starters, I
would never pop a dialog for the output of a communications error handler.
You can have a screen full of dialogs before you know what was happened. How
about log it to a memo?

Dave

Back to top
David Reeve
Guest





PostPosted: Mon Mar 01, 2004 12:55 am    Post subject: Re: Simple TCP Reply with quote

"Peter" <google (AT) sale-net (DOT) com.au> wrote

Quote:
Hi David.
Thanks for the time taken so far.
Well I have some code allocated to the ONERROR event already. My
understanding is that it doesn't have to handle specific errors but I
may be wrong. As you mentioned, I simply have the code firing a beep.
I could change it to a LOG to MEMO type function.

Get it to drop the error message into a memo. That is useful thing to have
anyway when you are trying to understand what is going on.

Quote:

I haven't got it raising a diag box at all. It seems the component
does that and as you mentioned, it fills the screen in no time. Hence
thats where my problem is. I have code in the Onerror event and yet
the boxes still appear when I seem to have lost one of the clients in
the list....

Hmmm... if you aren't popping the dialog, who is? Absolutely certain it's
not an exception dialog that's being popped? It would have the text message
you mention. However, if you have attached an OnError handler, then an
exception shouldn't be raised. Put a breakpoint on line 606 of
SimpleTCP.pas ..... if Assigned(FOnError) then..... and see what happens. It
is certain that this error handler is the source of the error text, but it
would be good to prove this before we get too involved.

Dave



Back to top
Peter
Guest





PostPosted: Tue Mar 02, 2004 11:44 am    Post subject: Re: Simple TCP Reply with quote

Sorry David. Now I look at it I would say you are right.It is an exception box....



"David Reeve" <dree4456 (AT) big-pond (DOT) net.au> wrote

Quote:
"Peter" <google (AT) sale-net (DOT) com.au> wrote in message
news:6a3f6a71.0402291215.76edcd87 (AT) posting (DOT) google.com...
Hi David.
Thanks for the time taken so far.
Well I have some code allocated to the ONERROR event already. My
understanding is that it doesn't have to handle specific errors but I
may be wrong. As you mentioned, I simply have the code firing a beep.
I could change it to a LOG to MEMO type function.

Get it to drop the error message into a memo. That is useful thing to have
anyway when you are trying to understand what is going on.


I haven't got it raising a diag box at all. It seems the component
does that and as you mentioned, it fills the screen in no time. Hence
thats where my problem is. I have code in the Onerror event and yet
the boxes still appear when I seem to have lost one of the clients in
the list....

Hmmm... if you aren't popping the dialog, who is? Absolutely certain it's
not an exception dialog that's being popped? It would have the text message
you mention. However, if you have attached an OnError handler, then an
exception shouldn't be raised. Put a breakpoint on line 606 of
SimpleTCP.pas ..... if Assigned(FOnError) then..... and see what happens. It
is certain that this error handler is the source of the error text, but it
would be good to prove this before we get too involved.

Dave

Back to top
David Reeve
Guest





PostPosted: Wed Mar 03, 2004 12:18 am    Post subject: Re: Simple TCP Reply with quote


"Peter" <google (AT) sale-net (DOT) com.au> wrote

Quote:
Sorry David. Now I look at it I would say you are right.It is an exception
box....



Aahh that's better. Assign an OnError handler and use it drop the error
message into a memo..... that should do the trick.

Dave



Back to top
Peter
Guest





PostPosted: Thu Mar 04, 2004 12:44 pm    Post subject: Re: Simple TCP Reply with quote

Hi again David. First off let me say THANKS for the help so far.

However, even before I posted the original question, I had some code
assigned to the ONERROR event for the server component. I have tried a
simple BEEP in that event but still getting a screen full.

Does the code have to be anything specific? My understanding is as
long as some code exists in the event?

Regards, Peter



"David Reeve" <dree4456 (AT) big-pond (DOT) net.au> wrote

Quote:
"Peter" <google (AT) sale-net (DOT) com.au> wrote in message
news:6a3f6a71.0403020344.6965cc1d (AT) posting (DOT) google.com...
Sorry David. Now I look at it I would say you are right.It is an exception
box....



Aahh that's better. Assign an OnError handler and use it drop the error
message into a memo..... that should do the trick.

Dave

Back to top
David Reeve
Guest





PostPosted: Thu Mar 04, 2004 1:29 pm    Post subject: Re: Simple TCP Reply with quote


"Peter" <google (AT) sale-net (DOT) com.au> wrote

Quote:
Hi again David. First off let me say THANKS for the help so far.

However, even before I posted the original question, I had some code
assigned to the ONERROR event for the server component. I have tried a
simple BEEP in that event but still getting a screen full.

Does the code have to be anything specific? My understanding is as
long as some code exists in the event?


Does the OnError event ever run? I'd set a breakpoint on ln 609 (add
SimpleTCP.pas to your project if you haven't already done so) and check that
it is indeed this line that is raising the exception. It really has to be,
but there is nothing like checking the basics first. If it is then, why is
Assigned(FOnError) returning false?

Sudden thought.... have you installed TSimpleTCPServer on the palette, or
are you creating it in your code? If its the later don't forget to connect
your error handler to the OnError event.... that would give the behaviour
you are seeing.

Dave



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc 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.