Brunet.Transport.TcpEdgeListener.SetSocketOpts C# (CSharp) Метод

SetSocketOpts() публичный статический Метод

public static SetSocketOpts ( Socket s ) : void
s Socket
Результат void
    public static void SetSocketOpts(Socket s) {
      s.Blocking = false; //Make sure the socket is not blocking
      //s.NoDelay = true; //Disable Nagle
      /*
       * I'm not sure this is helping at all, but we are doubling
       * the usual buffer size in the hopes that it will reduce
       * problems of lost packets.
       * 
       * The below makes sure the socket buffer can hold at least
       * one of the largest packets plus the 2 bytes needed to 
       * describe the size of the packet.
       */
      s.SendBufferSize = TcpEdge.MAX_PACKET + 2;
      s.ReceiveBufferSize = TcpEdge.MAX_PACKET + 2;
    }

Usage Example

Пример #1
0
 /**
  * Called when the socket is writable
  */
 public void HandleWritability(Socket s)
 {
     try {
         if (s.Connected)
         {
             TcpEdgeListener.SetSocketOpts(s);
             TcpEdge e = new TcpEdge(TEL, false, s);
             Result.Value = e;
             //Handle closes in the select thread:
             CloseAction ca = new CloseAction(e, TEL.ActionQueue);
             e.CloseEvent += ca.CloseHandler;
             //Set the edge
             TEL.ActionQueue.Enqueue(this);
         }
         else
         {
             //This did not work out, close the socket and release the resources:
             HandleError(s);
         }
     }
     catch (Exception) {
         //This did not work out, close the socket and release the resources:
         //Console.WriteLine("Exception: {0}", x);
         HandleError(s);
     }
 }
All Usage Examples Of Brunet.Transport.TcpEdgeListener::SetSocketOpts