public void Ctor_CanSend() { using (var udpClient = new DerivedUdpClient()) { Assert.Equal(1, udpClient.Send(new byte[1], 1, new IPEndPoint(IPAddress.Loopback, UnusedPort))); Assert.False(udpClient.Active); } }
public void Ctor_StringInt_CanSend() { using (var udpClient = new DerivedUdpClient("localhost", UnusedPort)) { Assert.Equal(1, udpClient.Send(new byte[1], 1)); Assert.True(udpClient.Active); } }
public FormBlockDistChart(string machine_name) { InitializeComponent(); //_machineName = machine_name; _dataQueue = new Queue <BlockDistances>(_maxCount); _localIp = Functions.GetIPAddressV4(); _udpClient = new DerivedUdpClient(_localIp, _localPort, true, false); _udpClient.DataReceived += new DataReceivedEventHandler(UdpClient_DataReceived); this.InitChart(); }
public void Active_Roundtrips() { using (var udpClient = new DerivedUdpClient()) { Assert.False(udpClient.Active); udpClient.Active = true; Assert.True(udpClient.Active); udpClient.Active = false; Assert.False(udpClient.Active); } }
public void Send_InvalidArguments_Throws() { using (var udpClient = new DerivedUdpClient()) { Assert.Throws <ArgumentNullException>("dgram", () => udpClient.Send(null, 0)); Assert.Throws <ArgumentNullException>("dgram", () => udpClient.Send(null, 0, "localhost", 0)); Assert.Throws <ArgumentNullException>("dgram", () => udpClient.Send(null, 0, new IPEndPoint(IPAddress.Loopback, 0))); Assert.Throws <InvalidOperationException>(() => udpClient.Send(new byte[1], 1)); udpClient.Active = true; Assert.Throws <InvalidOperationException>(() => udpClient.Send(new byte[1], 1, new IPEndPoint(IPAddress.Loopback, 0))); } }
public override void Init() { Const.WriteConsoleLog("初始化UDP..."); udp = new DerivedUdpClient(this.IpAddress, this.Port, true, false); Const.WriteConsoleLog(string.Format("{0}已启动", udp.Name)); }
public override void Init() { _udp = new DerivedUdpClient(Const.LocalIp, CHART_LOCAL_PORT, true, false); }
public override void Init() { Const.WriteConsoleLog("初始化建模服务数据发送UDP..."); udp = new DerivedUdpClient(Const.LocalIp, Config.UdpModelLocalPort, true, false); Const.WriteConsoleLog(string.Format("建模服务数据发送UDP{0}已启动", udp.Name)); }