using supersocket.socketbase;
using supersocket.socketbase.protocol;
using system;
using system.collections.generic;
using system.linq;
using system.text;
using system.threading.tasks;
namespace supersockettest.src.service.udpserver
protected
override
void
handleunknownrequest
(stringrequestinfo requestinfo)
protected
override
void
handleexception
(exception e)
protected
override
void
onsessionclosed
(closereason reason)
}}
using supersocket.socketbase;
using supersocket.socketbase.config;
using supersocket.socketbase.protocol;
using system;
using system.collections.generic;
using system.linq;
using system.text;
using system.threading.tasks;
namespace supersockettest.src.service.udpserver
protected
override
bool
setup
(irootconfig rootconfig,
iserverconfig config)
protected
override
void
onstopped()
}}
using supersocket.socketbase.command;
using supersocket.socketbase.protocol;
using system;
using system.collections.generic;
using system.linq;
using system.text;
using system.threading.tasks;
namespace supersockettest.src.service.udpserver
}public
override
void
executecommand
(mysession session,
stringrequestinfo requestinfo)
}}
<?xml version="1.0" encoding="utf-8" ?>
>
>
name
="supersocket"
type
="supersocket.socketengine.configuration.socketserviceconfig, supersocket.socketengine"
/>
configsections
>
>
>
name
="sstudp"
servertype
="supersockettest.src.service.udpserver.myserver,supersockettest"
ip="any"
port
="2020"
mode
="udp"
>
server
>
servers
>
supersocket
>
>
version
="v4.0"
sku=".netframework,version=v4.5"
/>
startup
>
configuration
>
using supersocket.socketbase;
using supersocket.socketengine;
using system;
using system.collections.generic;
using system.linq;
namespace supersockettest
var result = bootstrap.
start()
; console.
writeline
("啟動結果: !"
, result);if
(result == startresult.failed)
console.
writeline
("按 『q』 鍵停止伺服器。");
while
(console.
readkey()
.keychar !=
'q')
console.
writeline()
;//關閉伺服器
bootstrap.
stop()
; console.
writeline
("伺服器已停止!");
console.
readkey()
;}}}
using supersocket.socketbase;
using supersocket.socketbase.config;
using supersocket.socketbase.protocol;
using supersocket.socketengine;
using system;
using system.collections.generic;
using system.linq;
using system.text;
using system.threading.tasks;
namespace supersockettest))
//配置伺服器
console.
writeline()
;//嘗試啟動伺服器if(
start()
) console.
writeline
("伺服器啟動成功,按 『q』 鍵停止伺服器!");
//註冊新連線
=new
sessionhandler
<
>
;//註冊命令響應
=new
requesthandler
<
,stringrequestinfo
>
;while
(console.
readkey()
.keychar !=
'q')
//停止伺服器
stop()
; console.
writeline
("伺服器已停止!");
console.
readkey()
;}///
/// 處理第一次連線
///
/// socket會話
private
static
void
(///
/// 處理命令
///
/// socket會話
/// 請求的內容,詳見官方文件
private
static
void
(stringrequestinfo requestinfo)}}
}
C superSocket簡單示例
兩個端,乙個服務端,乙個客戶端。都是控制台程式。顯然地,服務端的要引用supersocket,但引用後編譯時候會提示,所以最終引用的內容如圖所示 supersocket內建了log4net,所以會有圖中所示。然後上 服務端 using system using system.linq using s...
django uwsgi nginx 配置並啟動
os ubuntu 18.04 django 2.0.4 python 3.6 uwsgi 2.0.17 nginx 1.14.0 django 是後端框架,主要進行的是邏輯處理 其自帶 wsgi伺服器 位置 project name wsgi.py 可用於除錯,但高併發情況無法達到要求。uwsgi...
Ubuntu 下配置開機自啟
ubuntu 系統下配置程式自動啟動有三種常用方法 init.d 配置守護程序 systemd 配置守護程序 ubuntu 14.04 以後版本 本文介紹通過systemd配置守護程序的方法實現開機自啟,以常用的安全隧道軟體gost為例,將乙個可執行檔案配置為系統服務。掌握該方法後,可以在 ubun...