static void Main(string[] args) { 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); Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); FileDirectory = config.AppSettings.Settings["FileDirectory"].Value; if (FileDirectory == "") FileDirectory = Path.Combine(Directory.GetCurrentDirectory(), "Files"); if (!Directory.Exists(FileDirectory)) Directory.CreateDirectory(FileDirectory); int port = 0; if (!(int.TryParse(config.AppSettings.Settings["Port"].Value, out port))) port = 9999; int parallelNum = 0; if (!(int.TryParse(config.AppSettings.Settings["ParallelNum"].Value, out parallelNum))) parallelNum = 8000; int socketTimeOutMS = 0; if (!(int.TryParse(config.AppSettings.Settings["SocketTimeOutMS"].Value, out socketTimeOutMS))) socketTimeOutMS = 5 * 60 * 1000; AsyncSocketSvr = new AsyncSocketServer(parallelNum); AsyncSocketSvr.SocketTimeOutMS = socketTimeOutMS; AsyncSocketSvr.Init(); IPEndPoint listenPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port); AsyncSocketSvr.Start(listenPoint); Console.WriteLine("Press any key to terminate the server process...."); Console.ReadKey(); }
public BaseSocketProtocol(AsyncSocketServer asyncSocketServer, AsyncSocketUserToken asyncSocketUserToken) : base(asyncSocketServer, asyncSocketUserToken) { m_userName = ""; m_logined = false; m_socketFlag = ""; }
public UploadSocketProtocol(AsyncSocketServer asyncSocketServer, AsyncSocketUserToken asyncSocketUserToken) : base(asyncSocketServer, asyncSocketUserToken) { m_socketFlag = "Upload"; m_fileName = ""; m_fileStream = null; lock (m_asyncSocketServer.UploadSocketProtocolMgr) { m_asyncSocketServer.UploadSocketProtocolMgr.Add(this); } }
public LogOutputSocketProtocol(AsyncSocketServer asyncSocketServer, AsyncSocketUserToken asyncSocketUserToken) : base(asyncSocketServer, asyncSocketUserToken) { m_socketFlag = "LogOutput"; m_logFixedBuffer = new LogFixedBuffer(); lock (Program.AsyncSocketSvr.LogOutputSocketProtocolMgr) { Program.AsyncSocketSvr.LogOutputSocketProtocolMgr.Add(this); } SendResponse(); }
public DownloadSocketProtocol(AsyncSocketServer asyncSocketServer, AsyncSocketUserToken asyncSocketUserToken) : base(asyncSocketServer, asyncSocketUserToken) { m_socketFlag = "Download"; m_fileName = ""; m_fileStream = null; m_sendFile = false; m_packetSize = 64 * 1024; lock (m_asyncSocketServer.DownloadSocketProtocolMgr) { m_asyncSocketServer.DownloadSocketProtocolMgr.Add(this); } }
public AsyncSocketInvokeElement(AsyncSocketServer asyncSocketServer, AsyncSocketUserToken asyncSocketUserToken) { m_asyncSocketServer = asyncSocketServer; m_asyncSocketUserToken = asyncSocketUserToken; m_netByteOrder = false; m_incomingDataParser = new IncomingDataParser(); m_outgoingDataAssembler = new OutgoingDataAssembler(); m_sendAsync = false; m_connectDT = DateTime.UtcNow; m_activeDT = DateTime.UtcNow; }
public RemoteStreamSocketProtocol(AsyncSocketServer asyncSocketServer, AsyncSocketUserToken asyncSocketUserToken) : base(asyncSocketServer, asyncSocketUserToken) { m_socketFlag = "RemoteStream"; m_fileStream = null; }
public ThroughputSocketProtocol(AsyncSocketServer asyncSocketServer, AsyncSocketUserToken asyncSocketUserToken) : base(asyncSocketServer, asyncSocketUserToken) { m_socketFlag = "Throughput"; }
public DaemonThread(AsyncSocketServer asyncSocketServer) { m_asyncSocketServer = asyncSocketServer; m_thread = new Thread(DaemonThreadStart); m_thread.Start(); }
public ControlSocketProtocol(AsyncSocketServer asyncSocketServer, AsyncSocketUserToken asyncSocketUserToken) : base(asyncSocketServer, asyncSocketUserToken) { m_socketFlag = "Control"; }