zoukankan      html  css  js  c++  java
  • C# SuperSocket服务端入门(一)

    1,新建一个控制台应用程序,.NET版本4.0

    2,添加SuperSocket(1.6.1).BinariesNet40Debug  目录下的:

    SuperSocket的dll文件(

    log4net.dll,

    SuperSocket.Common.dll,

    SuperSocket.SocketBase.dll,

    SuperSocket.SocketEngine.dll)到此项目的引用

    【你也可以使用日志框架,这里没有使用】

    3,添加系统的 
    System.Configuration;

    System.Configuration.Install;到引用中

    4,在默认的Program.cs 代码中 添加 命名空间 
    using SuperSocket.Common;
    using SuperSocket.SocketBase;
    using SuperSocket.SocketEngine;

    using SuperSocket.SocketBase.Config;

    5,详见代码:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
     
    using SuperSocket.Common;
    using SuperSocket.SocketBase;
    using SuperSocket.SocketEngine;
    using SuperSocket.SocketBase.Config;
     
    namespace WebSocketSeviceConsole
    {
        class Program
        {
            static void Main(string[] args)
            {
                Console.WriteLine("service");
                //实例化服务器对象
                AppServer appServer = new AppServer();
                var serverConfig = new ServerConfig();
     
                //ip: 服务器监听的ip地址。你可以设置具体的地址,也可以设置为下面的值 Any 
                //serverConfig.Ip = "184.56.41.24";
     
                serverConfig.Port = 8848;
                if (!appServer.Setup(serverConfig))
                { 
                    Console.WriteLine("Failed to setup!");
                    return;
                }
                if (!appServer.Start())
                {
                    Console.WriteLine("Failed to start!");
                    return;
                }
                Console.WriteLine("ssssss前置机启动成功!,输入q关闭服务器");
                while (Console.ReadKey().KeyChar != 'q')
                {
                    continue;
                }
                appServer.Stop();
                Console.WriteLine("服务器已经关闭");
                Console.ReadKey();
            }
        }
    }
  • 相关阅读:
    hbase coprocessor 二级索引
    文档:ubuntu安装.pdf
    Python过滤敏感词汇
    nginx 对django项目的部署
    ZooKeeper 的常用操作方法
    Python操作reids
    教你为nginx 配置ssl 证书!
    单线程多任务异步爬虫
    go语言入门之环境的搭建
    关于csrf跨站请求伪造攻击原理,与csrftoken防范原理
  • 原文地址:https://www.cnblogs.com/zxtceq/p/7280674.html
Copyright © 2011-2022 走看看