OctoTorrent.Client.SocketListener.Start C# (CSharp) Method

Start() public method

public Start ( ) : void
return void
        public override void Start()
        {
            if (Status == ListenerStatus.Listening)
                return;

            try
            {
                _listener = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                _listener.Bind(Endpoint);
                _listener.Listen(6);
                _listener.BeginAccept(_endAcceptCallback, _listener);
                RaiseStatusChanged(ListenerStatus.Listening);
            }
            catch (SocketException)
            {
                RaiseStatusChanged(ListenerStatus.PortNotFree);
            }
        }

Usage Example

 public void Setup()
 {
     endpoint = new IPEndPoint(IPAddress.Loopback, 55652);
     listener = new SocketListener(endpoint);
     listener.Start();
     System.Threading.Thread.Sleep(100);
 }