public new void Stop() { if (_sockServer == null) { return; //すでに終了処理が終わっている } base.Stop(); //life=false すべてのループを解除する _sockServer.Close(); // 全部の子スレッドが終了するのを待つ while (Count() > 0) { Thread.Sleep(500); } _sockServer = null; }
public new void Stop() { if (_sockServer == null) { return; //���łɏI���������I����Ă��� } base.Stop(); //life=false �ł��ׂẴ��[�v�������� _sockServer.Close(); // �S���̎q�X���b�h���I������̂�҂� while (Count() > 0) { Thread.Sleep(500); } _sockServer = null; }
public void getLocalAddress(String title, ProtocolKind protocolKind) { var bindIp = new Ip(IpKind.V4Localhost); const int port = 9991; const int listenMax = 10; Ssl ssl = null; var sockServer = new SockServer(new Kernel(), protocolKind, ssl); ThreadStart action = () => { if (protocolKind == ProtocolKind.Tcp) { sockServer.Bind(bindIp, port, listenMax); } else { sockServer.Bind(bindIp, port); } }; var _t = new Thread(action) { IsBackground = true }; _t.Start(); while (sockServer.SockState == SockState.Idle) { Thread.Sleep(200); } var localAddress = sockServer.LocalAddress; Assert.That(localAddress.ToString(), Is.EqualTo("127.0.0.1:9991")); //bind()後 localAddressの取得が可能になる var remoteAddress = sockServer.RemoteAddress; Assert.IsNull(remoteAddress); //SockServerでは、remoteAddressは常にnullになる sockServer.Close(); }
protected override void OnRunThread() { var port = (int)Conf.Get("port"); var bindStr = string.Format("{0}:{1} {2}", _oneBind.Addr, port, _oneBind.Protocol); Logger.Set(LogKind.Normal, null, 9000000, bindStr); //DOSを受けた場合、multiple数まで連続アクセスまでは記憶してしまう //DOSが終わった後も、その分だけ復帰に時間を要する //Ver5.9,2 Java fix //_sockServer = new SockServer(this.Kernel,_oneBind.Protocol); _sockServer = new SockServer(Kernel, _oneBind.Protocol, ssl); //Ver5.9.2 Java fix if (ssl != null && !ssl.Status) { Logger.Set(LogKind.Error, null, 9000024, bindStr); //[C#] ThreadBaseKind = ThreadBaseKind.Running; } else { if (_sockServer.SockState != sock.SockState.Error) { if (_sockServer.ProtocolKind == ProtocolKind.Tcp) { RunTcpServer(port); } else { RunUdpServer(port); } } } //Java fix _sockServer.Close(); Logger.Set(LogKind.Normal, null, 9000001, bindStr); }
protected override void OnRunThread() { var port = (int)Conf.Get("port"); var bindStr = string.Format("{0}:{1} {2}", _oneBind.Addr, port, _oneBind.Protocol); Logger.Set(LogKind.Normal, null, 9000000, bindStr); //DOS����ꍇ�Amultiple���܂ŘA���A�N�Z�X�܂ł͋L�����Ă��܂� //DOS���I��������A���̕��������A�Ɏ��Ԃ�v���� //Ver5.9,2 Java fix //_sockServer = new SockServer(this.Kernel,_oneBind.Protocol); _sockServer = new SockServer(Kernel, _oneBind.Protocol, ssl); //Ver5.9.2 Java fix if (ssl != null && !ssl.Status) { Logger.Set(LogKind.Error, null, 9000024, bindStr); //[C#] ThreadBaseKind = ThreadBaseKind.Running; } else { if (_sockServer.SockState != sock.SockState.Error) { if (_sockServer.ProtocolKind == ProtocolKind.Tcp) { RunTcpServer(port); } else { RunUdpServer(port); } } } //Java fix _sockServer.Close(); Logger.Set(LogKind.Normal, null, 9000001, bindStr); }
public void startStop(String title, ProtocolKind protocolKind) { var bindIp = new Ip(IpKind.V4Localhost); const int port = 8881; const int listenMax = 10; Ssl ssl = null; var sockServer = new SockServer(new Kernel(), protocolKind, ssl); Assert.That(sockServer.SockState, Is.EqualTo(SockState.Idle)); ThreadStart action = () => { if (protocolKind == ProtocolKind.Tcp) { sockServer.Bind(bindIp, port, listenMax); } else { sockServer.Bind(bindIp, port); } }; var _t = new Thread(action) { IsBackground = true }; _t.Start(); while (sockServer.SockState == SockState.Idle) { Thread.Sleep(100); } Assert.That(sockServer.SockState, Is.EqualTo(SockState.Bind)); sockServer.Close(); //bind()にThreadBaseのポインタを送っていないため、isLifeでブレイクできないので、selectで例外を発生させて終了する Assert.That(sockServer.SockState, Is.EqualTo(SockState.Error)); }
protected override void OnStopThread() { _sockServer.Close(); }