Exemplo n.º 1
0
        public UDPConnection(EndPoint local) : base(new Socket(local.AddressFamily, SocketType.Dgram, ProtocolType.Udp))
        {
            Local = local;

            // do this so remote cant close socket https://docs.microsoft.com/en-us/windows/desktop/WinSock/winsock-ioctls
            ConnectionSocket.IOControl((IOControlCode)SIO_UDP_CONNRESET, new byte[] { 0, 0, 0, 0 }, null);
        }
Exemplo n.º 2
0
 /// <param name="waitTime">specifies the time (in milliseconds) between the last communication and the first keep alive attempt</param>
 /// <param name="interval">interval (in milliseconds) between each keep alive attempt</param>
 public void SetUpKeepAlive(int waitTime, int interval)
 {
     byte[] inputValues = new byte[3 * sizeof(uint)];
     BitConverter.GetBytes(1).CopyTo(inputValues, 0);    // enable flag
     BitConverter.GetBytes(waitTime).CopyTo(inputValues, sizeof(uint));
     BitConverter.GetBytes(interval).CopyTo(inputValues, sizeof(uint) * 2);
     ConnectionSocket.IOControl(IOControlCode.KeepAliveValues, inputValues, null);
 }