static void WrapperExample(NpcReflector npcReflector, INpcHtmlGenerator htmlGenerator, UInt16 port) { NpcServerSingleThreaded wrapper = new NpcServerSingleThreaded(NpcLoggerCallback.ConsoleLogger, npcReflector, htmlGenerator, port); wrapper.Run(); }
public NpcBlockingThreadHander(String clientString, INpcServerCallback callback, Socket socket, NpcExecutor npcExecutor, INpcHtmlGenerator npcHtmlGenerator) : base(clientString, callback, npcExecutor, npcHtmlGenerator) { this.socket = socket; this.socketLineReader = new SocketLineReader(socket, Encoding.ASCII, Buf.DefaultInitialCapacity, Buf.DefaultExpandLength); }
public NpcServerSingleThreaded(INpcServerCallback callback, NpcExecutor npcExecutor, INpcHtmlGenerator htmlGenerator, UInt16 port) { if (callback == null) { throw new ArgumentNullException("callback"); } if (npcExecutor == null) { throw new ArgumentNullException("npcExecutor"); } if (htmlGenerator == null) { throw new ArgumentNullException("htmlGenerator"); } this.callback = callback; this.npcExecutor = npcExecutor; this.htmlGenerator = htmlGenerator; Socket listenSocket = new Socket(IPAddress.Any.AddressFamily, SocketType.Stream, ProtocolType.Tcp); listenSocket.Bind(new IPEndPoint(IPAddress.Any, port)); listenSocket.Listen(Backlog); callback.ServerListening(listenSocket); selectServer = new SelectServer(false, new Buf(SingleThreadedReceiveBufferLength)); selectServer.control.AddListenSocket(listenSocket, AcceptCallback); }
public NpcSelectServerHandler(INpcServerCallback callback, NpcExecutor npcExecutor, INpcHtmlGenerator htmlGenerator) { if (callback == null) { throw new ArgumentNullException("callback"); } if (npcExecutor == null) { throw new ArgumentNullException("npcExecutor"); } if (htmlGenerator == null) { throw new ArgumentNullException("htmlGenerator"); } this.callback = callback; this.npcExecutor = npcExecutor; this.htmlGenerator = htmlGenerator; }
public NpcHandler(String clientString, INpcServerCallback callback, NpcExecutor npcExecutor, INpcHtmlGenerator npcHtmlGenerator) { if (callback == null) { throw new ArgumentNullException("callback"); } if (npcExecutor == null) { throw new ArgumentNullException("npcExecutor"); } if (npcHtmlGenerator == null) { throw new ArgumentNullException("npcHtmlGenerator"); } this.clientString = clientString; this.callback = callback; this.npcExecutor = npcExecutor; this.htmlGenerator = npcHtmlGenerator; }
public NpcServerMultiThreaded(INpcServerCallback callback, NpcExecutor npcExecutor, INpcHtmlGenerator htmlGenerator, UInt16 port) { if (callback == null) { throw new ArgumentNullException("callback"); } if (npcExecutor == null) { throw new ArgumentNullException("npcReflector"); } if (htmlGenerator == null) { throw new ArgumentNullException("htmlGenerator"); } this.callback = callback; this.npcExecutor = npcExecutor; this.htmlGenerator = htmlGenerator; this.port = port; this.keepRunning = false; }
public NpcServerSingleThreaded(INpcServerCallback callback, NpcExecutor npcExecutor, INpcHtmlGenerator htmlGenerator, Socket listenSocket) { if (callback == null) { throw new ArgumentNullException("callback"); } if (npcExecutor == null) { throw new ArgumentNullException("npcExecutor"); } if (htmlGenerator == null) { throw new ArgumentNullException("htmlGenerator"); } this.callback = callback; this.npcExecutor = npcExecutor; this.htmlGenerator = htmlGenerator; selectServer = new SelectServer(false, new Buf(SingleThreadedReceiveBufferLength)); selectServer.control.AddListenSocket(listenSocket, AcceptCallback); }
static void NoWrapperExample(NpcReflector npcReflector, INpcHtmlGenerator htmlGenerator, UInt16 port) { // // Accept Connections Loop // Socket listenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); listenSocket.Bind(new IPEndPoint(IPAddress.Any, port)); listenSocket.Listen(32); while (true) { Socket clientSocket = listenSocket.Accept(); String clientString = clientSocket.RemoteEndPoint.ToString(); Console.WriteLine("{0} [ListenThread] New Client '{1}'", DateTime.Now, clientString); NpcBlockingThreadHander npcHandler = new NpcBlockingThreadHander(NpcLoggerCallback.ConsoleLogger, clientSocket, npcReflector, htmlGenerator); Thread handlerThread = new Thread(npcHandler.Run); handlerThread.Start(); } }
public NpcSocketHandler(String clientString, INpcServerCallback callback, NpcExecutor npcExecutor, INpcHtmlGenerator npcHtmlGenerator) : base(clientString, callback, npcExecutor, npcHtmlGenerator) { if (callback == null) { throw new ArgumentNullException("callback"); } this.lineParser = new LineParser(Encoding.ASCII, Buf.DefaultInitialCapacity, Buf.DefaultExpandLength); }