Написал элементарый connection на UDS, а он не работает
SereverUdpClient server;
IPEndPoint receivePoint;
int port = 6767; //Port for the Server to use
int ip = 127001;//IP Address 127.0.0.1
server = new UdpClient(2055);
//Define a Receive point
receivePoint = new IPEndPoint(new IPAddress(ip), port);
while (true)
{
Thread.Sleep(1000);
byte[] frame = Encoding.ASCII.GetBytes("Test");
// byte[] frame = (byte[])cam.GrabFrame(30);
Console.WriteLine("Grabed " + frame.Length+ "bytes");
//We use the IP and Port sent by the user to send the DataGram back
server.Send(frame, frame.Length, receivePoint);
}
Client public partial class Form1 : Form
{
private UdpClient client;
private IPEndPoint receivePoint;
private int port = 6565; //Port for the Client to use
private int ip = 127001;//IP Address 127.0.0.1
private Bitmap bmp;
string message="init";
public Form1()
{
InitializeComponent();
client = new UdpClient(2056,AddressFamily.InterNetwork);
receivePoint = new IPEndPoint(new IPAddress(ip), port);
Thread t = new Thread(new ThreadStart(start_client));
t.Start();
}
public void Run()
{
lblMsg.Text = message;
}
public void start_client()
{
while (true)
{
message = "d";
this.Invoke(new MethodInvoker(Run));
IPEndPoint ep = null;// new IPEndPoint(IPAddress.Any, 6565);
byte[] recData = client.Receive(ref ep);
message = "Data length =" + recData.Length + " " + Encoding.ASCII.GetString(recData);
this.Invoke(new MethodInvoker(Run));
}
}
}
"d" отрисовывается, но текст, что я должен получить по UDP нет. Подскажите в чём дело?
/**********Comments***************************/
We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With gr
Данное сообщение получено с сайта GotDotNet.RU
Последний раз редактировалось 15 December 2006 22:50
|