简体   繁体   中英

SuperSocket can't set up a server

I am writing this to find out why the code below is resulting in failed setup for supersocket server.

    var appServer = new AppServer();
    if (!appServer.Setup(8080)){
        MessageBox.Show("Failed!");
    }

I have added rule in firewall that allows port 8080 since my firewall is enabled by company IT. Don't know why the setup fails. Is there an explanation?

In testing this locally in a console application using the following (requires NuGet packages SuperSocket and SuperSocket.Engine ;

namespace SupersocketTest
{
    using System;
    using SuperSocket.SocketBase;

    class Program
    {
        static void Main(string[] args)
        {
            var server = new AppServer();
            bool success = server.Setup(8080);
            Console.WriteLine($"Server setup: {success}");
            Console.ReadKey();
        }
    }
}

The operation completes successfully.

Looking at the code online, the underlying connection is still Socket based (as the name of the package implies). As such, it's subject to all the rules around how sockets work normally in .NET.

Things that can cause a Socket fail to be set up are (but not limited to)

  • The socket is in use
  • The socket has been closed
  • The OS has run out of available sockets (not likely but technically possible)

Without more detail on the exception you're getting I can only guess but I suspect that the socket is in use as 8080 is a common alternative to 80 that another application could be using.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM