/// <summary> /// Bind to the given end point and configuration. /// </summary> /// <param name="endPoint">The endpoint for receiving data.</param> /// <param name="configure">The <see cref="SocketListener"/> configuration options features.</param> public void Listen(IPEndPoint endPoint, SocketListenerOptionsDelegate configure) { if (endPoint == null) { throw new ArgumentNullException(nameof(endPoint)); } var listenOptions = new SocketListenerOptions(endPoint); configure(listenOptions); Listener = listenOptions; }
/// <summary> /// Bind to the given ip address, port and configuration. /// </summary> /// <param name="address">The ip address for receiving data.</param> /// <param name="port">The port for receiving data.</param> /// <param name="configure">The <see cref="SocketListener"/> configuration options features.</param> public void Listen(IPAddress address, int port, SocketListenerOptionsDelegate configure) { if (address == null) { throw new ArgumentNullException(nameof(address)); } if (port > IPEndPoint.MaxPort || port < IPEndPoint.MinPort) { throw new ArgumentOutOfRangeException(nameof(port), $"Must be less then { IPEndPoint.MaxPort } and greater then { IPEndPoint.MinPort }."); } Listen(new IPEndPoint(address, port), configure); }
/// <summary> /// Bind to the given ip address, port and configuration. /// </summary> /// <param name="port">The port for receiving data.</param> /// <param name="configure">The <see cref="SocketListener"/> configuration options features.</param> public void Listen(int port, SocketListenerOptionsDelegate configure) { Listen(IPAddress.Any, port, configure); }