2009-05-15 19 views
0

Jungs Ich brauche etwas Hilfe hier .. Ich mache ein Projekt in C#, wo die Daten als Datagramm gesendet werden und auch empfangen werden, die gesendet wird.Senden und Empfangen von Broadcast-Nachrichten

Im Folgenden ist der Code:

public void StartUdpListener(Object state) 
    { 

     receivedNotification = udpServer.Receive(ref remoteEndPoint); 
     notificationReceived = Encoding.ASCII.GetString(receivedNotification); 

     listBox = new StringBuilder(this.listBox1.Text); 
     listBox.AppendLine(notificationReceived); 


     if (listBox1.InvokeRequired) 
     { 
      this.Invoke((MethodInvoker)delegate { this.listBox1.Items.Add(listBox.ToString()); }); 
     } 



    } 

    public void StartNotification() 
    { 

     ThreadPool.QueueUserWorkItem(new WaitCallback(StartUdpListener)); 

     hostName = Dns.GetHostName(); 
     hostBuffer = Encoding.ASCII.GetBytes(hostName); 

     UdpClient newUdpClient = new UdpClient(); 
     newUdpClient.Send(hostBuffer, hostBuffer.Length, notifyIP); 



    } 

Könnten Sie mir bitte sagen, Jungs, wenn der Code in Ordnung ist, weil niemand in der Nähe ist, mit dem ich Dank einer Tonne Jungs den Code auf lan testen kann.

Antwort