简体   繁体   English

SuperSocket无法设置服务器

[英]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. 我在防火墙中添加了允许端口8080的规则,因为我的防火墙是由公司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 ; 在使用以下内容在控制台应用程序中进行本地测试时(需要NuGet包SuperSocketSuperSocket.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). 在线查看代码 ,底层连接仍然是基于Socket的(正如包的名称所暗示的)。 As such, it's subject to all the rules around how sockets work normally in .NET. 因此,它受到有关套接字如何在.NET中正常工作的所有规则的约束。

Things that can cause a Socket fail to be set up are (but not limited to) 可能导致Socket无法设置的事情是(但不限于)

  • 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. 没有关于你得到的异常的更多细节我只能猜测,但我怀疑套接字正在使用,因为8080是另一个应用程序可能正在使用的80的常见替代。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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