rx432
rx432

Reputation: 93

stop timeouts server side?

In my client I have done:

TcpClient client = new TcpClient();
client.ReceiveTimeout = 1000;
client.SendTimeout = 1000;

I also get marks for doing it server side, I tried checking with intellisense on my TCPListener in my server, but I cant find anything.

Any ideas?

Upvotes: 0

Views: 1242

Answers (1)

M.Babcock
M.Babcock

Reputation: 18965

On the server side, you're using TcpListener which is nothing more than a Socket or TcpClient factory.

Somewhere in the server code you'll see either AcceptTcpClient or AcceptSocket (or their async counterparts). Something like:

TcpClient clientConn = listener.AcceptTcpClient();

Now you have the equivalent of client from the code snippet in your question. So to set the timeouts:

clientConn.ReceiveTimeout = 1000;
clientConn.SendTimeout = 1000;

You can do something similar with Socket instances if that is what it uses (I can dig up some code if this is the case), but in general it is pretty much the same.

UPDATE

Since on the server side you're using AcceptSocket rather than AcceptTcpClient, you can use the following:

Socket clientConn = listener.AcceptSocket();
clientConn.ReceiveTimeout = 1000;
clientConn.SendTimeout = 1000;

It's basically identical, just using a different type for clientConn.

Upvotes: 3

Related Questions