Socket timeout

J

Johan

Hi

I'm working with sockets and I'm curious about the timout when trying to
connect to a server on a specific port.

My code looks like this:

Socket client = new
Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);
int port = Int32.Parse( TextBox_Port.Text );
string ip = TextBox_IP.Text;
ipAdd = IPAddress.Parse( ip );
remoteEP = new IPEndPoint ( ipAdd, port );
client.Connect (remoteEP);

What I can't get a grip on is the long timout period if the server does not
respond.

I've tried adding:

client.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.SendTimeout, 500);
client.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.SendTimeout, 500);

but this does not help...

Is there a way of controling the timeout on connect?

/Johan
 
J

Johan

Sorry, of course the second "client.SetSocketOption" stated ReceiveTimeout,
I just made a typo.
None of these work...

Johan.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top