public void Echoサーバにsendしてlength分ずつRecvする() { //setUp const string addr = "127.0.0.1"; const int port = 53; var echoServer = new EchoServer(addr, port); echoServer.Start(); const int timeout = 3; const int max = 1500; const int loop = 10; var tmp = new byte[max]; for (int i = 0; i < max; i++){ tmp[i] = (byte) i; } var ip = new Ip(addr); for (var i = 0; i < loop; i++){ var sockUdp = new SockUdp(new Kernel(), ip, port, null, tmp); // while (sockUdp.Length() == 0){ // Thread.Sleep(10); // } var b = sockUdp.Recv(timeout); //verify for (var m = 0; m < max; m += 10){ Assert.That(b[m], Is.EqualTo(tmp[m])); //送信したデータと受信したデータが同一かどうかのテスト } sockUdp.Close(); } //TearDown echoServer.Stop(); }
public void OneServerを継承したEchoServer_UDP版_を使用して接続する() { const string addr = "127.0.0.1"; const int port = 9991; const int timeout = 300; Ip ip = null; try{ ip = new Ip(addr); } catch (ValidObjException ex){ Assert.Fail(ex.Message); } var oneBind = new OneBind(ip, ProtocolKind.Udp); var conf = TestUtil.CreateConf("OptionSample"); conf.Set("port", port); conf.Set("multiple", 10); conf.Set("acl", new Dat(new CtrlType[0])); conf.Set("enableAcl", 1); conf.Set("timeOut", timeout); var echoServer = new EchoServer(conf, oneBind); echoServer.Start(); //TCPクライアント const int max = 1600; var buf = new byte[max]; buf[8] = 100; //CheckData for (int i = 0; i < 3; i++){ var sockUdp = new SockUdp(new Kernel(), ip, port, null, buf); var b = sockUdp.Recv(timeout); Assert.That(b[8], Is.EqualTo(buf[8])); //CheckData Assert.That(max, Is.EqualTo(b.Length)); sockUdp.Close(); } echoServer.Dispose(); }