PC Review


Reply
Thread Tools Rate Thread

connect timeout for synchronous socket connection

 
 
=?Utf-8?B?T3Bh?=
Guest
Posts: n/a
 
      10th Apr 2005
Hi,

..NET Sockets does not provide a ConnectTimeout when calling the Connect
method while establishing a Synchronous socket connection. Instead, my
app is forced to wait a very long time before and Exception is thrown if the
server i'm trying to connect to is not listening.

Has anyone written any code to mimmick a connect timeout for a synchronous
socket connect? Please share.

Thanks a lot.


 
Reply With Quote
 
 
 
 
Joerg Jooss
Guest
Posts: n/a
 
      10th Apr 2005
Opa wrote:

> Hi,
>
> .NET Sockets does not provide a ConnectTimeout when calling the
> Connect method while establishing a Synchronous socket connection.
> Instead, my app is forced to wait a very long time before and
> Exception is thrown if the server i'm trying to connect to is not
> listening.


You can specify both send and receive timeouts using
Socket.SetSocketOption(), e.g.


int timeout = 2000; // in milliseconds
socket.SetSocketOption(
SocketOptionLevel.Socket,
SocketOptionName.SendTimeout,
timeout);

Cheers,
--
http://www.joergjooss.de
mailto:news-(E-Mail Removed)
 
Reply With Quote
 
=?Utf-8?B?T3Bh?=
Guest
Posts: n/a
 
      10th Apr 2005
The SendTimeOut option is used for timeouts on Send not initial connects.
I am using the .NET CF to connect synchronously and need to set a timeout
for the Connect method.

Any other ideas?

"Joerg Jooss" wrote:

> Opa wrote:
>
> > Hi,
> >
> > .NET Sockets does not provide a ConnectTimeout when calling the
> > Connect method while establishing a Synchronous socket connection.
> > Instead, my app is forced to wait a very long time before and
> > Exception is thrown if the server i'm trying to connect to is not
> > listening.

>
> You can specify both send and receive timeouts using
> Socket.SetSocketOption(), e.g.
>
>
> int timeout = 2000; // in milliseconds
> socket.SetSocketOption(
> SocketOptionLevel.Socket,
> SocketOptionName.SendTimeout,
> timeout);
>
> Cheers,
> --
> http://www.joergjooss.de
> mailto:news-(E-Mail Removed)
>

 
Reply With Quote
 
Joerg Jooss
Guest
Posts: n/a
 
      12th Apr 2005
Opa wrote:

> The SendTimeOut option is used for timeouts on Send not initial
> connects. I am using the .NET CF to connect synchronously and need
> to set a timeout for the Connect method.
>
> Any other ideas?


Hm, I kind of assumed that the Send timeout applies for Connect() as
well.

Cheers,

--
http://www.joergjooss.de
mailto:news-(E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
synchronous socket connection closed error =?Utf-8?B?S2V2aW4=?= Microsoft C# .NET 4 17th May 2006 02:49 AM
Connect a socket with timeout Mike Schilling Microsoft C# .NET 3 5th Apr 2006 08:09 AM
Socket.Connect() timeout Ted Burhan Microsoft ASP .NET 2 19th Dec 2003 03:45 AM
Socket.Connect() Timeout, please help Ted Burhan Microsoft C# .NET 2 19th Dec 2003 03:44 AM
Socket.Connect() timeout, help Ted Burhan Microsoft Dot NET Framework 0 19th Dec 2003 01:41 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:07 AM.