Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi All,

 

Anyone know how to set the timeout value for a client socket thats trying to asynchronously connect to a server.

 

I know this seems dumb since its connecting asynchronously, but i'd still like to shorten the timeout value.

 

For example :

 


client = New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.IP)
' set timeout value
' client.timeout ????
' asynchronous connect        
client.BeginConnect(EP, AddressOf sockconnected, client)
       

 

Thanks

  • *Gurus*
Posted

I don't believe so, only for sending and receiving data. I asked a friend, and he doesn't believe BSD sockets offer a way of doing this, he has unsuccessful in finding a way to do it with winsock and win32 either.

 

Your best bet is probably to use a timer and do it yourself.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Posted

Hi,

 

Thanks for your help.. ok, so if i use a timer.. how do i end the connection attempt after starting it asynchronously?.. i.e. would it not still try to fire the callback function whenever it does timeout?

 

Thanks again for your help - im new enough to sockets

  • 10 months later...
Posted

Long time in comming but here is a response

 

m_DataSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout, 60000);

m_DataSocket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 60000);

 

This is more for people who are lookign for the answer now then to answer your question. I was looking and happend to find it in some example of FTP. Anyway, here it is.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...