代码拉取完成,页面将自动刷新
using LJLib.TcpHandle;
using LoanSvr;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Net;
using System.Net.Sockets;
using System.ServiceProcess;
using System.Threading;
using LJLib.D;
using LJLib.DAL.SQL;
using LJLib.HttpServer;
using LJLib.Tools.File;
using LoanSvr.BLL;
namespace LoanSvr
{
partial class LoanSvr : ServiceBase
{
private TcpListener _tcpListener = null;
private static bool running = false;
public LoanSvr()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
try
{
DbSqlHelper.Add(new SqlServerEngine());
GlobalVar.webapp = false;
GlobalVar.Init();
XmlConfig xmlconfig = new XmlConfig();
var strport = xmlconfig.GetXmlFileValue(GlobalVar.XmlFile, string.Empty, "port", "9075");
var strHttpPort = xmlconfig.GetXmlFileValue(GlobalVar.XmlFile, string.Empty, "httpport", "9076");
int port = int.Parse(strport);
int httpport = int.Parse(strHttpPort);
startHttpListener(httpport);
_tcpListener = new TcpListener(IPAddress.Any, port);
_tcpListener.Start();
ThreadPool.QueueUserWorkItem((state) =>
{
running = true;
// 侦听线程
Thread.CurrentThread.IsBackground = false;
try
{
while (running)
{
if (_tcpListener.Pending())
{
var c = _tcpListener.AcceptTcpClient();
ThreadPool.QueueUserWorkItem((st) =>
{
try
{
Thread.CurrentThread.IsBackground = true;
var handler = new P1Server(c, GlobalVar.server);
handler.Handle();
}
catch (Exception ex)
{
Trace.Write("服务处理线程(直连)异常退出:" + ex.ToString());
}
DebugHelper.PrintAll();
});
}
else
{
Thread.Sleep(100);
}
}
}
catch (Exception ex)
{
Trace.Write("主侦听线程异常退出:" + ex.ToString());
}
});
}
catch (Exception ex)
{
Trace.Write(ex.ToString());
}
}
protected override void OnStop()
{
running = false;
}
private void startHttpListener(int port)
{
#if DEBUG
var httpServer = new SimpleHttpServer(port, GlobalVar.server, null);
#else
var httpServer = new SimpleHttpServer(port, GlobalVar.server, null);
#endif
httpServer.Listen();
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。