| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net.Sockets;
- using System.Text;
- using System.Threading.Tasks;
- namespace SKMC.Api.Common.Tcp
- {
- /// <summary>
- /// TCP服务器接口
- /// </summary>
- public interface ITcpServer
- {
- /// <summary>
- /// 设定服务参数
- /// </summary>
- /// <param name="address">Host地址</param>
- /// <param name="port">Host端口</param>
- /// <param name="keepAlived">是否长连接</param>
- void SetHost(string address, int port, bool keepAlived);
- /// <summary>
- /// 开启服务 (需要开新线程)
- /// </summary>
- /// <param name="cacheSize">最大请求队列数</param>
- /// <param name="worker">string输入输出工作</param>
- void Listen(int cacheSize, Func<string, string> worker);
- /// <summary>
- /// 开启服务 (需要开新线程)
- /// </summary>
- /// <param name="cacheSize">最大请求队列数</param>
- /// <param name="worker">socket数据处理工作</param>
- void Listen(int cacheSize, Action<Socket> worker);
- /// <summary>
- /// 关闭服务
- /// </summary>
- void Close();
- }
- }
|