Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Jul : (Indy 9) TIdTCPClient.Connect() causes Socket Error 10061?
| Subject: | (Indy 9) TIdTCPClient.Connect() causes Socket Error 10061? |
| Posted by: | "Mark Huebner" (mhuebn..@bostwicklaboratories.com) |
| Date: | Tue, 3 Jul 2007 13:05:40 |
I have a Windows service application that uses both TIdTCPServer and
TIdTCPClient of Indy 9 inside a custom Delphi 7 component which handles data
communication with a medical instrument. Inside my component's
TIdTCPServer.OnExecute event, I generate a component event for the Windows
service and pass it the message received. In certain instances, the Windows
service event that processes the message received calls a component method
that tries to execute a TIdTCPClient.Connect() to send a message to the
medical instrument. This causes an Exception "Project
CentaurInterface_Service.exe raised exception class EIdSocketError with
message "Socket Err.r #10061 ... Connection refused".
I'm currently using the code below in the component method that calls the
component method (OutputWorkList) containing the TIdTCPClient.Connect() to
tell whether it is safe to execute. However, I don't think this is looking
at the right properties to tell if it is safe to execute OutputWorkList.
Can someone tell me what I should examine to determine that it is safe to
call OutputWorkList and not generate a Socket Error 10061? Thanks in
advance!
var
ActiveServerThreads : Tlist ;
begin
CentaurWorkList := WorkList ;
ActiveServerThreads := IdTCPServer.Threads.LockList ;
IdTCPServer.Threads.UnlockList ;
if (ActiveServerThreads.Count = 0) then
OutputWorkList ;
end ;