internal TcpClientInfo(ITcpHandler parent, TcpClient client, HandlerType type, int timeout, int buffersize) { Parent = parent; Client = client; HndlType = type; Timeout = timeout; BufferSize = buffersize; WriteSync = new ThreadSafeHelper <int>(); }
/// <summary> /// Create an FtpProgress, with the download / upload length in bytes. /// </summary> /// <param name="len">The total length in bytes of the download / upload</param> public FtpProgress(long len) { TotalLength = len; CurrentCount = 0L; RateCount = 0L; BytesPerSecond = 0L; RateSync = new ThreadSafeHelper <byte>(); RateTimer = new Timer(1000); RateTimer.Elapsed += RateTimer_Elapsed; }
/// <summary> /// Create a TCP server, with the given address, port, read timeout and backlog limit. /// </summary> /// <param name="address">The address to listen</param> /// <param name="port">The port to listen</param> /// <param name="readTimeout">The default read timeout</param> /// <param name="backlog">The backlog</param> /// <param name="maxClients">The maximum amount of clients. Default to Int.MaxValue</param> /// <param name="buffersize">The buffer size when reading messages</param> public TcpServerHandler(IPAddress address, int port, int readTimeout = 0, int backlog = 100, int maxClients = int.MaxValue, int buffersize = TcpClientInfo.BUFFERSIZE) { Listener = new TcpListener(new IPEndPoint(address, port)); Clients = new ConcurrentDictionary <TcpClient, TcpClientInfo>(); Backlog = backlog; ReadTimeout = readTimeout; isListening = false; MaxClients = maxClients; BufferSize = buffersize; StateSync = new ThreadSafeHelper <int>(); }
/// <summary> /// Create an HTTP server, given the prefix (ie: "http://localhost:8080") and weither the server start listening immediately. /// </summary> /// <param name="prefixes">The prefix (ie: "http://localhost:8080")</param> /// <param name="andStart">Should the server start now</param> public HttpServerHandler(string[] prefixes, bool andStart = false) { Listener = new HttpListener(); StateSync = new ThreadSafeHelper <int>(); if (prefixes != null) { foreach (var pref in prefixes) { Listener.Prefixes.Add(pref); } } Listen(andStart); }