Board index » delphi » Will I be able to Stop a Blocking Winsock Process

Will I be able to Stop a Blocking Winsock Process

Hi
  I am writing a winsock client program , I set it to blocking but
sometimes when there is no response from the server , the program waits
infinitely .. if I can break the function it will be great.thanks

 

Re:Will I be able to Stop a Blocking Winsock Process


[This followup was posted to comp.lang.pascal.delphi.misc and a copy was
sent to the cited author.]

In article <33C42F0A....@netvigator.com>, kevin...@netvigator.com says...

Quote
> Hi
>   I am writing a winsock client program , I set it to blocking but
> sometimes when there is no response from the server , the program waits
> infinitely .. if I can break the function it will be great.thanks

I don't think there is a way to do this, apart from putting your sockets
code on another thread, and using your main application thread to
terminate the socket thread.

However, you might like to look at WSACancelBlockingHook etc. - they
might be useful.

I would suggest that you avoid blocking sockets wherever possible - on
some levels they are simpler (more like normal programming) but problems
like this complicate the issue a great deal. Non-blocking sockets, as
used by dWinsock and some freeware components, offer greater simplicity
if your application has a GUI... blocking sockets are better suited to
non-GUI processes in my opinion :)

You certainly don't want to block on your main application thread - your
user will think your program has crashed!

-------------------------------------------------------
Marc Palmer, AnyWare Ltd.              

Co-author of dWinsock http://www.aait.com/dwinsock
   Author of AppTools http://www.anyware.co.uk
      Fan of Cardiacs http://www.anyware.co.uk/cardiacs

Other Threads