المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : UdpClient Error : Only one usage of each socket address (protocol/network address/port) is normally permitted



C# Programming
08-27-2009, 12:45 AM
Hello everyone,
I am having trouble with UdpClient class. Here is my code:
private UdpClient myClient;
private void button1_Click(object sender, EventArgs e)
{
myClient = new UdpClient(7777);
}

private void button2_Click(object sender, EventArgs e)
{
myClient.Close();
}
So when I press button1 to connect for the first time - Everything is OK
when I press button2 to discconect - Everything is OK
But when I try to connect for the second time by pressnig button1 I get the error : "Only one usage of each socket address (protocol/network address/port) is normally permitted"

How can I solve this problem? How can I bind my socket again? Any help will be appreciated.

Regards