Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / May 2005

Tip: Looking for answers? Try searching our database.

How: Affecting TcpClient Connect( ) timeout ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lee Gillie - 02 May 2005 23:12 GMT
I have seen some suggest you use the ReadTimeout and WriteTimeout
properties to control this, but I have tried this, and it does not work.
 I have a difficult to reproduce scenario where connection attempts are
hanging for 5 minutes before eventually failing. I need a much shorter
timeout on my client.

I think the delay is that the server has partially started negotiating
the connection - the OS has answered the call, but the bind has not
passed off the incoming connection request to the server process yet.
The server runs on VMS.
Lee Gillie - 03 May 2005 16:58 GMT
> I have seen some suggest you use the ReadTimeout and WriteTimeout
> properties to control this, but I have tried this, and it does not work.
[quoted text clipped - 6 lines]
> passed off the incoming connection request to the server process yet.
> The server runs on VMS.

Ok, I think I figure this out.

One wants to make a Socket and manually connect it asynchronously using
BeginConnect. A manual reset event can then time the attempt to connect,
and stall the caller until either the asynchronous connect activity
occurs, or else the timed manual reset event wait expires. Once a
manually connected socket has been made, the next issue is how to get
the TcpClient to use it. There is a Client property on TcpClient, but
one must derive a from TcpClient to use it.  I simply wrapped up all the
timeout enabled connect methods in this wrapper class. I provided
overlaods to the base class Connect routines which add a timeout
parameter. I chose to exclude the DNS work from the timeout.

- Lee

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.