Пример #1
0
 public HttpToCdpClient(String clientEndPointString, Socket clientSocket, HttpToCtpSelectServerHandler serverHandler)
 {
     this.clientEndPointString = clientEndPointString;
     this.clientSocket         = clientSocket;
     this.serverHandler        = serverHandler;
     this.httpHeaderBuilders   = new StringBuilder();
 }
Пример #2
0
        static void Main(string[] args)
        {
            HttpToCtpLogger.logger      = Console.Out;
            HttpToCtpLogger.errorLogger = Console.Out;

            //
            // Options
            //
            Int32 backlog = 32;

            Int32     listenPort = 8080;
            IPAddress listenIP   = null;

            //HttpToCtp.proxySelector = new SingleConnectorSelector(
            //    new GatewayProxy(new DnsEndPoint("proxy.houston.hp.com", 8080, true)));

            IPEndPoint listenEndPoint = (listenIP == null) ?
                                        new IPEndPoint(IPAddress.Any, listenPort) :
                                        new IPEndPoint(listenIP, listenPort);

            SelectServer selectServer = new SelectServer(false, new Buf(4096, 4096));

            {
                Socket listenSock = new Socket(listenEndPoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
                listenSock.Bind(listenEndPoint);
                listenSock.Listen(backlog);

                HttpToCtpSelectServerHandler server = new HttpToCtpSelectServerHandler();
                selectServer.control.AddReceiveSocket(listenSock, server.AcceptCallback);
            }

            selectServer.Run();
        }