KcpServerConnection.cs 942 B

12345678910111213141516171819202122
  1. using System.Net;
  2. using System.Net.Sockets;
  3. namespace kcp2k
  4. {
  5. public class KcpServerConnection : KcpConnection
  6. {
  7. // Constructor & Send functions can be overwritten for where-allocation:
  8. // https://github.com/vis2k/where-allocation
  9. public KcpServerConnection(Socket socket, EndPoint remoteEndPoint, bool noDelay, uint interval = Kcp.INTERVAL, int fastResend = 0, bool congestionWindow = true, uint sendWindowSize = Kcp.WND_SND, uint receiveWindowSize = Kcp.WND_RCV, int timeout = DEFAULT_TIMEOUT)
  10. {
  11. this.socket = socket;
  12. this.remoteEndPoint = remoteEndPoint;
  13. SetupKcp(noDelay, interval, fastResend, congestionWindow, sendWindowSize, receiveWindowSize, timeout);
  14. }
  15. protected override void RawSend(byte[] data, int length)
  16. {
  17. socket.SendTo(data, 0, length, SocketFlags.None, remoteEndPoint);
  18. }
  19. }
  20. }