Hello
I have socket:
System.Net.Sockets.Socket oSocket = new
Socket(IPAddress.Any.AddressFamily,SocketType.Stre am,ProtocolType.Tcp); IPEndPoint
endPoint = new IPEndPoint(IPAddress.Parse(ip),portNum);
oSocket.Blocking=false;
oSocket.Connect(endPoint);
.....
while (CountinueThread)
{
int BytesRead = oSocket.Receive(bytes);
....
Thread.Sleep(200);
}
as far as i understeand: if there is nothing to Receive thread
continues. How do i know there is nothing to receive ? Can i set timeout
in any way ? Is it possible that i will receive only part of packet ?
The main problem is that using non-blocking socket here my program thru
exeption:
" System.Net.Sockets.SocketException: Non-blocking Socket operation
could not been finished, but was finished imediately".
Why ?
Other problem: when i used blocking socket and try to set:
LingerOption lingerOption = new LingerOption(true, 1);
oSocket.SetSocketOption(SocketOptionLevel.Socket,
SocketOptionName.Linger, lingerOption);
nothing changed, when in other thread i closed socket, after about 3
second receive function thru exeption that socket was closed.
When i tried to set that time to 10 seconds, noting changed too
(response was after 3 second too).
How can i set time after Socket.Receive notice that connection is broken ?
Thanx