示例#1
0
        public void Listen(IPEndPoint hostEndPoint)
        {
            InternalSocket.Bind(hostEndPoint);

            InternalSocket.Listen(100);

            InternalSocket.BeginAccept(AcceptCallback, this);
        }
示例#2
0
        public void Listen(int port)
        {
            InternalSocket.Bind(new IPEndPoint(IPAddress.Any, port));

            InternalSocket.Listen(100);

            InternalSocket.BeginAccept(AcceptCallback, this);
        }
示例#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.");
            }
        }