Add LowLatency setter to INetworkSocket

This commit is contained in:
UnknownShadow200 2017-07-19 17:50:56 +10:00
parent 9062dbc68f
commit 282edd2ca3
2 changed files with 7 additions and 0 deletions

View File

@ -26,6 +26,9 @@ namespace MCGalaxy.Network {
/// <summary> Gets the remote IP of this socket. </summary>
string RemoteIP { get; }
/// <summary> Sets whether this socket operates in low-latency mode (e.g. for TCP, disabes nagle's algorithm). </summary>
bool LowLatency { set; }
/// <summary> Receives next block of received data, asynchronously. </summary>
void ReceiveNextAsync();

View File

@ -33,6 +33,10 @@ namespace MCGalaxy.Network {
get { return ((IPEndPoint)socket.RemoteEndPoint).Address.ToString(); }
}
public bool LowLatency {
set { socket.NoDelay = value; }
}
static AsyncCallback recvCallback = new AsyncCallback(ReceiveCallback);
public void ReceiveNextAsync() {
socket.BeginReceive(tempbuffer, 0, tempbuffer.Length, SocketFlags.None, recvCallback, this);