Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Controlling the timeout

Status
Not open for further replies.

B00gyeMan

Programmer
Jan 14, 2004
259
RO
I have this situation:

1) There is a server on machine S which exposes type T through .NET remoting.
2) There is a client on another machine C which attempts to remotely instantiate the type T on machine S using Activator.GetObject method.

If the S machine is running but the server application (which exposes type T) isn't running, you will get an System.Net.Sockets.SocketException with ErrorCode set to 10061 meaning "No connection could be made because the target machine actively refused it."

If the S machine itself is NOT running you will get an System.Net.Sockets.SocketException with ErrorCode set to 10060 meaning "A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.", but after an unreasonable (in my opinion) long timeout.

How can I control this timeout? (Within the client applications, of course [pipe])

10x.
 
Use asynchronous calls: BeginConnect() with AsyncCallback
delegate.
That delegate will try to connect to the remote machine and then signals the application thread that the connection is complete by using a global ManualResetEvent object (calling WaitOne()).
Use the same pattern for "send" and "receive" e.g. BeginSend() and BeginReceive().
-obislavu-
 
Actually, what I needed was to shorten the timeout, and I finally got an answer which is:

"The TcpChannel doesn't use any timeout at all and also doesn't even allow any timeouts to be set.

For the HttpChannel, things are a little bit different. There's no default timeout, but you can set one using code like the following:

SomeObject obj = Activator.GetObject(typeof(SomeObject),"IDictionary dict = ChannelServices.GetChannelSinkProperties(obj);
dict["timeout"] = 10;

Best regards,
Ingo Rammer
Author of "Advanced .NET Remoting"
and "Advanced .NET Remoting in VB .NET
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top