Forcing TCPClient to time out....

  • Thread starter Thread starter Eric Cathell
  • Start date Start date
E

Eric Cathell

I have an application that I am using to send documents to printers over a
network. If the printer is powered off, or in configuration mode, or the
client bridge is down, the tcpclient just hangs....I need a way to make it
time out and continue to the loop....any know a way i can do that? say if it
doesnt connect in 10 seconds to timeout and continue the loop?

Eric
 
Hi Eric,
I do it always on another way, but this is something for the
system.timers.timer I think.
As far as I know works it in a seperate thread and is allways thrown.
Cor
 
hmmm...that could be tricky for me then, because i already have that loop on
a timer that is fired by a spool event....
if you need to see some code let me know...

ERic
 
Hi Eric,
Maybe someting as this is a solution (hand written and partialy pseudo)
\\\
threadprint.start
x = 0
' this can be set by the public ready event of threadprint to 201
' but I think there are nicer methods too
do while x < 200
threading.thread.sleep(50) 'this is the maintread
application.doevents
loop
if x = 200 threadprint.abort
///
Just a thought again not tested.

Cor
 
Check out the Timeouts for Sockets and TcpClient stuff

TheSocket.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.SendTimeout, 10000)

TheSocket.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.ReceiveTimeout, 10000)

System.Net.Sockets.TcpClient.ReceiveTimout = 10000
System.Net.Sockets.TcpClient.SendTimeout = 10000

good luck!
Shawn Shelton
 
Back
Top