diff --git a/MCGalaxy/Network/Socket/Interfaces.cs b/MCGalaxy/Network/Socket/Interfaces.cs index 58a4a408f..cd24087d5 100644 --- a/MCGalaxy/Network/Socket/Interfaces.cs +++ b/MCGalaxy/Network/Socket/Interfaces.cs @@ -26,6 +26,9 @@ namespace MCGalaxy.Network { /// Gets the remote IP of this socket. string RemoteIP { get; } + /// Sets whether this socket operates in low-latency mode (e.g. for TCP, disabes nagle's algorithm). + bool LowLatency { set; } + /// Receives next block of received data, asynchronously. void ReceiveNextAsync(); diff --git a/MCGalaxy/Network/Socket/TcpSocket.cs b/MCGalaxy/Network/Socket/TcpSocket.cs index 343005527..0b3a8b5d0 100644 --- a/MCGalaxy/Network/Socket/TcpSocket.cs +++ b/MCGalaxy/Network/Socket/TcpSocket.cs @@ -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);