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

推荐订阅源

S
Schneier on Security
P
Proofpoint News Feed
Apple Machine Learning Research
Apple Machine Learning Research
WordPress大学
WordPress大学
博客园 - Franky
V
V2EX
爱范儿
爱范儿
J
Java Code Geeks
小众软件
小众软件
Last Week in AI
Last Week in AI
The Cloudflare Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Hugging Face - Blog
Hugging Face - Blog
T
The Blog of Author Tim Ferriss
酷 壳 – CoolShell
酷 壳 – CoolShell
The Register - Security
The Register - Security
GbyAI
GbyAI
Vercel News
Vercel News
Y
Y Combinator Blog
腾讯CDC
F
Fortinet All Blogs
I
InfoQ
N
Netflix TechBlog - Medium
B
Blog RSS Feed
D
Docker
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
量子位
博客园 - 司徒正美
阮一峰的网络日志
阮一峰的网络日志
The GitHub Blog
The GitHub Blog
Microsoft Security Blog
Microsoft Security Blog
V
Visual Studio Blog
博客园 - 三生石上(FineUI控件)
宝玉的分享
宝玉的分享
Blog — PlanetScale
Blog — PlanetScale
H
Help Net Security
云风的 BLOG
云风的 BLOG
A
About on SuperTechFans
Scott Helme
Scott Helme
T
Tor Project blog
U
Unit 42
Google Online Security Blog
Google Online Security Blog
PCI Perspectives
PCI Perspectives
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
NISL@THU
NISL@THU
D
Darknet – Hacking Tools, Hacker News & Cyber Security
aimingoo的专栏
aimingoo的专栏
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Stack Overflow Blog
Stack Overflow Blog
Security Archives - TechRepublic
Security Archives - TechRepublic

博客园 - 江大渔

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文件夹下的项目。