• SuperSocket


    配置和使用 Input Endpoint

    由于Windows Azure的内部网络架构,你不能直接监听你配置中的IP和端口。在这种情况下,你需要在Windows Azure项目中配置Input Endpoint:

    这些 endpoint的命名规则是 "AppServerName_ConfiguredListenPort"。

    例如,我们在配置文件中配置了名为"RemoteProcessServer"的server:

    <server name="RemoteProcessServer"

              serverTypeName="remoteProcess"

              ip="Any" port="2012" />

    然后我们就应该创建一个名为"RemoteProcessServer_2012"的Endpoint。

    在代码中,你可以通过编程的方式获得该Endpoint真正的端口号:

    var instanceEndpoint = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints[serverConfig.Name + "_" + serverConfig.Port].Port;

    但是你不用为SuperSocket这样做,因为 SuperSocket 已经实现了监听Endpoint的替换已经。 因此,你只需当SuperSocket的Bootstrap初始化的时候将Endpoint的字典传入就行了,最终代码如下:

    public override bool OnStart()

    {

        // Set the maximum number of concurrent connections

        ServicePointManager.DefaultConnectionLimit = 100;

        // For information on handling configuration changes

        // see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.

     
         m_Bootstrap = BootstrapFactory.CreateBootstrap();
     
        if (!m_Bootstrap.Initialize(RoleEnvironment.CurrentRoleInstance.InstanceEndpoints.ToDictionary(p => p.Key, p => p.Value.IPEndpoint)))
        {
            Trace.WriteLine("Failed to initialize SuperSocket!", "Error");
            return false;
        }
     
        var result = m_Bootstrap.Start();
     
        switch (result)
        {
            case (StartResult.None):
                Trace.WriteLine("No server is configured, please check you configuration!");
                return false;
     
            case (StartResult.Success):
                Trace.WriteLine("The server has been started!");
                break;
     
            case (StartResult.Failed):
                Trace.WriteLine("Failed to start SuperSocket server! Please check error log for more information!");
                return false;
     
            case (StartResult.PartialSuccess):
                Trace.WriteLine("Some server instances were started successfully, but the others failed to start! Please check error log for more information!");
                break;
        }
     
        return base.OnStart();
    }
    最后,你就可以启动你的Windows Azure实例了。
  • 相关阅读:
    后缀零
    vs2019 MFC的安装 解决 此项目需要 MFC 库。从 Visual Studio 安装程序(单个组件选项卡)为正在使用的任何工具集和体系结构安装它们。
    矩形切割
    fsync: failed to connect to feed.openvas.org (89.146.224.58)
    How to Install GVM Trial With VMware Workstation Player/Pro
    GVM 21.04 (stable, initial release 20210416)
    gitlab 升级相关
    Adobe Reader XI 11.0.23 简体中文版
    gofileserver GO HTTP 文件下载服务器
    KVM 中安装 Windows 10 虚拟机、CentOS 8 虚拟机及快照操作
  • 原文地址:https://www.cnblogs.com/fanweisheng/p/11127212.html
Copyright © 2020-2023  润新知