请教UdpClient发送问题
我想在两台PC机A和B间用C#的 UdpClient传输数据, 如果两边都用网上下载的ezUDP小程序 , 那么A.B两台PC收.发均正常. 而我用C#的 UdpClient写了一个简单程序放在机A上, 机B上仍用ezUDP小程序, 结果是: 机A能收到机B发来的数据, 反之. 机B却不能收到机A发来的数据. 弄了好久都解决不了, 真不知为什么? 请哪位朋友指教一下,谢谢!
附:1.两台PC机设置: 机A: IP=192.168.1.100, Port= 2000.
机B: IP=192.168.1.1, Port= 1180.
2. 电缆: 两台PC直连, 两个RJ45扦头均是这头的1 .2 脚分别接那头的3 .6 脚.
3. C#的 UdpClient程序与发送有关的部份如下:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using System.Text;
namespace UdpClientClient
{
public class Form1 : System.Windows.Forms.Form
{
private UdpClient sendUdp;
private IPEndPoint remoteIPEndPoint;
private IPAddress remoteIPAddr;
private string remoteIP = "192.168.1.2";
private int remotePort = 1180;
public Form1()
{
InitializeComponent();
}
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void btnSend_Click(object sender, System.EventArgs e)
{
try
{
remoteIPAddr = IPAddress.Parse(remoteIP);
remoteIPEndPoint = new IPEndPoint(remoteIPAddr, remotePort);
remoteIPEndPoint = new IPEndPoint(IPAddress.Parse(remoteIP), remotePort);
Wait();
sendUdp = new UdpClient(remotePort);
sendUdp.Connect(remoteIPEndPoint);
byte[] sendData = new Byte[5] { 128, 1, 1, 1, 128 };
sendUdp.Send(sendData, sendData.Length);
sendUdp.Close();
}
catch (Exception a)
{
ricRecBox.Text = a.ToString();
}
sendUdp.Close();
}
private void Wait()
{
int i,j,k;
k = 6;
for( i=0;i<8000;i++)
{
for (j = 0; j < 8000; j++)
{
k++;
k--;
}
}
}
}
}