Skip to content
Snippets Groups Projects
Commit bf5e9c41 authored by joalhelk's avatar joalhelk
Browse files

fixed timeouts

parent c7a24e56
No related branches found
No related tags found
No related merge requests found
......@@ -114,6 +114,7 @@ namespace TFTPServer
/// <param name="remote"></param>
private static bool WaitAcknowledge(int number, EndPoint remote)
{
socket.ReceiveTimeout = socket_timeout;
byte[] buffer = new byte[4];
try
{
......@@ -127,9 +128,12 @@ namespace TFTPServer
SendError(remote, ERROR_CODE.Not_defined, "invalid ack packet");
return false;
}
socket.ReceiveTimeout = 30000;
return true;
} catch (SocketException)
{
socket.ReceiveTimeout = 30000;
return false;
}
}
......@@ -329,7 +333,6 @@ namespace TFTPServer
{
socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
socket.Bind(iep);
socket.ReceiveTimeout = socket_timeout;
}
catch (Exception ex)
{
......@@ -355,15 +358,6 @@ namespace TFTPServer
case (int)PACKET_TYPE.WRQ:
WriteRequest(buffer, remote);
break;
case (int)PACKET_TYPE.DATA:
DataRequest(buffer);
break;
case (int)PACKET_TYPE.ACK:
AckResponse(buffer);
break;
case (int)PACKET_TYPE.ERROR:
ErrorResponse(buffer);
break;
default:
break;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment