473,385 Members | 1,740 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Forcing TCPClient to time out....

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
2 6331
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Daniel | last post by:
TcpClient close() method socket leak when i use TcpClient to open a connection, send data and close the TcpClient with myTcpClientInstance.Close(); it takes 60 seconds for the actual socket on...
3
by: Ricardo Quintanilla | last post by:
i had a problem whom i do not know how to explain. i was using a TcpClient (System.Net.Sockets.TcpClient) object to send and receive data to an AS400 socket. Two months ago it started to work...
8
by: Claire | last post by:
I'm trying to debug my network application ie I want to check my error handling when the connection is broken. Im using 127.0.0.1 as the connection address. Unfortunately, the client socket goes...
1
by: hamil | last post by:
I am having trouble using the TcpListener and TcpClient classes. At the end of this post is server code that runs, and a class whose purpose is described below. I need to know when the client...
12
by: Sebastian [IG&A::] | last post by:
Hi all, I'm using a TcpClient and it's stream to send data over a network. Now I'm noticing that my app is using a lot of memory, and I've noticed that everytime I need to send something over the...
1
by: Ryan Liu | last post by:
Hi, Why TcpClient has a method TcpClient.GetStream(), not just a read only property? By implementing it as a method, does that mean, each time GetStream() could return a different stream? In...
2
by: DrZoop | last post by:
Long story short: I am misusing the TCPClient class. I am sending 400-500 byte messages, and data is being lost. How can the TCPClient class be misused to lose data? Background notes: -I know...
4
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, I am wondering if I am using TCPClient class in C#, how to setup timeout value? Timeout I mean, when connects to server for the 1st time, and during <timeoutinterval, if no...
6
by: Bjoern Schliessmann | last post by:
Hello, I'm currently trying to implement a simulation program with Kamaelia and need a reliable TCP connection to a data server. From Twisted, I know that a method is called if the connection...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.