public NetLibServer(IPAddress localaddr, int port, TransferProtocolType protocol, Encoding encoding) { Protocol = new TransferProtocolFactory().CreateTransferProtocol(protocol, encoding, new Action<string>(Log)); if (protocol == TransferProtocolType.Delimited) { Delimiter = new byte[] { 13, 10 }; } Listener = new TcpListener(localaddr, port); }
public TransferProtocol CreateTransferProtocol(TransferProtocolType protocol, Encoding encoding, Action<string> logCallback) { switch (protocol) { case TransferProtocolType.Streaming: return new StreamingProtocol(encoding); case TransferProtocolType.Delimited: return new DelimitedProtocol(encoding, logCallback); case TransferProtocolType.FixedSize: return new FixedSizeProtocol(encoding); default: return null; } }
public NetLibClient(TransferProtocolType protocolType, Encoding encoding, IPEndPoint localEndPoint = null, int readLoopSleepTime = 50) { ReadLoopSleepTime = readLoopSleepTime; protocol = new TransferProtocolFactory().CreateTransferProtocol(protocolType, encoding, new Action<string>(Log)); if (localEndPoint != null) { Client = new TcpClient(localEndPoint); } else { Client = new TcpClient(); } Delimiter = new byte[] { 13, 10 }; ++clientCount; }
public NetLibServer(int port, TransferProtocolType protocol, Encoding encoding) : this(IPAddress.Any, port, protocol, encoding) { }