By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,462 Members | 1,126 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,462 IT Pros & Developers. It's quick & easy.

Forcing TCPClient to time out....

P: n/a
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
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Cor
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
Nov 20 '05 #2

P: n/a
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

Eric Cathell wrote:
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


Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.