Use SetSocketOption
s.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendTimeout,
m_nMilliseconds);
s.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout,
m_nMilliseconds);
"Peter Steele" <(E-Mail Removed)> wrote in message
news:%23GRGiK$(E-Mail Removed)...
> If I use TCPClient, it's straightforward to set the read timeout value for
> reading the associated stream:
>
> TcpClient myClient = new TcpClient(myaddr, myport);
> myClient.ReceiveTimeout = 5000;
> NetworkStream myClientStream = myClient.GetStream();
> myClientReader = new StreamReader(myClientStream );
>
> However, if I've just accepted a socket connection via a listener, the
> situation is a bit different. I
>
> clientSocket = server.AcceptSocket();
> NetworkStream myClientStream = new NetworkStream(clientSocket );
> myClientReader = new StreamReader(myClientStream);
>
> I'd like to do something like this:
>
> clientSocket.ReceiveTimeout = 5000;
>
> but there is not such method on sockets. So how can I do the equivalent
> operation of setting the timeout for a socket like I can do with a
TcpClient
> object?
>
>
|