惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Recent Commits to openclaw:main
Recent Commits to openclaw:main
Simon Willison's Weblog
Simon Willison's Weblog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Schneier on Security
Cyberwarzone
Cyberwarzone
NISL@THU
NISL@THU
The Last Watchdog
The Last Watchdog
Security Archives - TechRepublic
Security Archives - TechRepublic
The Hacker News
The Hacker News
Schneier on Security
Schneier on Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Help Net Security
Help Net Security
Scott Helme
Scott Helme
SecWiki News
SecWiki News
Security Latest
Security Latest
T
Threat Research - Cisco Blogs
L
LINUX DO - 最新话题
L
Lohrmann on Cybersecurity
TaoSecurity Blog
TaoSecurity Blog
K
Kaspersky official blog
Attack and Defense Labs
Attack and Defense Labs
P
Privacy & Cybersecurity Law Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
L
LINUX DO - 热门话题
N
News and Events Feed by Topic
Know Your Adversary
Know Your Adversary
Forbes - Security
Forbes - Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Google DeepMind News
Google DeepMind News
T
Tor Project blog
P
Palo Alto Networks Blog
Cisco Talos Blog
Cisco Talos Blog
A
Arctic Wolf
O
OpenAI News
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
AI
AI
N
News and Events Feed by Topic
博客园 - Franky
T
Threatpost
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Engineering at Meta
Engineering at Meta
S
SegmentFault 最新的问题
C
Cyber Attacks, Cyber Crime and Cyber Security
N
Netflix TechBlog - Medium
V2EX - 技术
V2EX - 技术
B
Blog RSS Feed
Hacker News: Ask HN
Hacker News: Ask HN
D
Docker
博客园 - 三生石上(FineUI控件)

博客园 - 江大渔

SuperSocket 2.0 发布第一个预览版, 另寻找Yang Fan哥哥 .NET Core 1.0 RC2 历险之旅 - 江大渔 使用LogMaster4Net实现应用程序日志的集中管理 SuperSocket 1.5 stable发布 在Mono/Linux上使用PerformanceCounter SuperSocket 1.5 文档列表 SuperWebSocket 0.5发布 WebSocket4Net 0.5发布 SuperWebSocket发布0.1版本 用ILMerge合并Silverlight, WindowsPhone或Mono for Android的程序集 SuperSocket 1.4 SP2 发布了! 无需等待,SuperSocket 1.4 SP1 发布了! SuperSocket 1.4 stable正式发布 SuperSocket 1.4系列文档(18) 在Unix/Linux操作系统中通过Mono运行SuperSocket SuperSocket 1.4系列文档(16) 在SuperSocket中启用传输层加密(TLS/SSL) SuperSocket 1.4系列文档(15) 在SuperSocket中启用内置Flash/Silverlight策略服务器 SuperSocket 1.4系列文档(14) 多服务器实例和服务器实例之间的交互 SuperSocket 1.4系列文档(13) 连接过滤器(Connection Filter) SuperSocket 1.4系列文档(12) 命令过滤器(Command Filter)
SuperSocket 1.4系列文档(17) 在Windows Azure中运行SuperSocket
江大渔 · 2011-05-16 · via 博客园 - 江大渔

Windows Azure是微软的云计算平台!Windows Azure通过微软的数据中心为开发人员提供以按需的计算能力和存储能力去托管、扩展和管理互联网上的应用程序。

运行于Windows Azure上的应用程序具有很高的可靠性和可伸缩性。

基于SuperSocket的服务器程序可以轻易的运行于Windows Azure平台之上。

和普通Socket服务器程序不同,首先需要在Role的属性中设置Socket程序对外提供服务的Endpoint:

M[90I@W~C78O1JN{4D@S@$9[4]

然后在WorkerRole代码文件中动态的获取外部Endpoint所对应的内部Endpoint:

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

完整的代码如下:

public override bool OnStart()
{
    LogUtil.Setup();
    // 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.
 
    var serverConfig = ConfigurationManager.GetSection("socketServer") as SocketServiceConfig;
 
    if (!SocketServerManager.Initialize(serverConfig, ResolveServerConfig))
    {
        Trace.WriteLine("Failed to initialize SuperSocket!", "Error");
        return false;
    }
 
    if (!SocketServerManager.Start())
    {
        Trace.WriteLine("Failed to start SuperSocket!", "Error");
        return false;
    }
 
    return base.OnStart();
}
 
private IServerConfig ResolveServerConfig(IServerConfig serverConfig)
{
    var config = new ServerConfig();
    serverConfig.CopyPropertiesTo(config);
 
    var instanceEndpoint = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints[serverConfig.Name + "Endpoint"];
    if (instanceEndpoint == null)
    {
        Trace.WriteLine(string.Format("Failed to find Input Endpoint configuration {0}!", serverConfig.Name + "Endpoint"), "Error");
        return serverConfig;
    }
 
    var ipEndpoint = instanceEndpoint.IPEndpoint;
    config.Ip = ipEndpoint.Address.ToString();
    config.Port = ipEndpoint.Port;
    return config;
}

就这样,你的SuperSocket服务器程序就可以正确的运行在Windows Azure平台之上。

完整的示例代码,请参考源代码中WindowsAzure文件夹下的项目。