码迷,mamicode.com
首页 > Windows程序 > 详细

添加SuperSocket的启动代码到 Windows Azure 的 WorkRole 项目

时间:2019-07-03 16:57:19      阅读:124      评论:0      收藏:0      [点我收藏+]

标签:write   str   point   service   art   msdn   rac   hang   socket   

与其它SuperSocket程序相同,启动代码同样也要写到程序的入口处,如 Windows Azure 的 WorkRole 项目的OnStart() 方法:

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())

    {

        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();

}

添加SuperSocket的启动代码到 Windows Azure 的 WorkRole 项目

标签:write   str   point   service   art   msdn   rac   hang   socket   

原文地址:https://www.cnblogs.com/fanweisheng/p/11127207.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!