public UChannel(USocket socket, UService service): base(service) { this.isConnected = true; this.socket = socket; this.service = service; this.remoteAddress = this.socket.RemoteAddress; }
public UChannel(USocket socket, UService service) : base(service) { this.isConnected = true; this.socket = socket; this.service = service; this.remoteAddress = this.socket.RemoteAddress; }
public void ClientSendToServer() { const string hostName = "127.0.0.1"; const ushort port = 8889; using (IService clientService = new UService(hostName, 8888)) { using (IService serverService = new UService(hostName, 8889)) { Task task1 = Task.Factory.StartNew(() => { while (!this.isClientStop) { clientService.Update(); } }, TaskCreationOptions.LongRunning); Task task2 = Task.Factory.StartNew(() => { while (!this.isServerStop) { serverService.Update(); } }, TaskCreationOptions.LongRunning); // 往server host线程增加事件,accept serverService.Add(() => this.ServerEvent(serverService)); Thread.Sleep(1000); // 往client host线程增加事件,client线程连接server clientService.Add(() => this.ClientEvent(clientService, hostName, port)); this.barrier.SignalAndWait(); serverService.Add(() => { this.isServerStop = true; }); clientService.Add(() => { this.isClientStop = true; }); Task.WaitAll(task1, task2); } } }
public UChannel(USocket socket, string host, int port, UService service): base(service) { this.socket = socket; this.service = service; this.remoteAddress = host + ":" + port; }
public UChannel(USocket socket, string host, int port, UService service) : base(service) { this.socket = socket; this.service = service; this.remoteAddress = host + ":" + port; }