Ejemplo n.º 1
0
        public void Listen(IPEndPoint hostEndPoint)
        {
            InternalSocket.Bind(hostEndPoint);

            InternalSocket.Listen(100);

            InternalSocket.BeginAccept(AcceptCallback, this);
        }
Ejemplo n.º 2
0
        public void Listen(int port)
        {
            InternalSocket.Bind(new IPEndPoint(IPAddress.Any, port));

            InternalSocket.Listen(100);

            InternalSocket.BeginAccept(AcceptCallback, this);
        }
Ejemplo n.º 3
0
        public void Start()
        {
            try
            {
                InternalSocket.Bind(ServerEndPoint);
                InternalSocket.Listen(500);
                InternalSocket.BeginAccept(EndAccepting, null);
            }
            catch (SocketException ex)
            {
                if (ex.ErrorCode == (int)SocketError.AddressAlreadyInUse)
                {
                    throw new InvalidOperationException("The selected port is already used by another process");
                }

                throw new NotSupportedException("oops unexpected error was thrown please report this issue to the developer.");
            }
        }