Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 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;
     }
 }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
 public NetLibServer(int port, TransferProtocolType protocol, Encoding encoding)
     : this(IPAddress.Any, port, protocol, encoding)
 {
 }