基线 SVN r240
SVN-Revision: r240
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
using System.Net;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
|
||||
namespace Lskj.SocketService
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
public static ILog Logger;
|
||||
|
||||
/// <summary>
|
||||
/// 应用程序的主入口点。
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
string _fileDirectory = @"E:\Scoket\Files";
|
||||
int _port = 9999;
|
||||
int _parallelNum = 8000;
|
||||
int _socketTimeOutMS = 5 * 60 * 1000;
|
||||
|
||||
DateTime currentTime = DateTime.Now;
|
||||
log4net.GlobalContext.Properties["LogDir"] = currentTime.ToString("yyyyMM");
|
||||
log4net.GlobalContext.Properties["LogFileName"] = "_SocketAsyncServer" + currentTime.ToString("yyyyMMdd");
|
||||
Logger = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
//Application.Run(new Form1());
|
||||
|
||||
try
|
||||
{
|
||||
SocketApp.FileDirectory = _fileDirectory;
|
||||
if (string.IsNullOrWhiteSpace(SocketApp.FileDirectory))
|
||||
SocketApp.FileDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Files");
|
||||
if (!Directory.Exists(SocketApp.FileDirectory))
|
||||
Directory.CreateDirectory(SocketApp.FileDirectory);
|
||||
|
||||
SocketApp.AsyncSocketSvr = new AsyncSocketServer(_parallelNum);
|
||||
SocketApp.AsyncSocketSvr.SocketTimeOutMS = _socketTimeOutMS;
|
||||
SocketApp.AsyncSocketSvr.Init();
|
||||
IPEndPoint listenPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), _port);
|
||||
SocketApp.AsyncSocketSvr.Start(listenPoint);
|
||||
|
||||
Console.Write("启动成功.等待连接.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.Write(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user