UdpClient Error : Only one usage of each socket address (protocol/network address/port) is normally permitted
-
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 -
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 -
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. RegardsWhy do you want to press button twice? When
UdpClient
's constructor is executed with a port number, it binds to the port number provided. You can't rebind to that port again. Once the binding is done, callConnect()
method to connect the socket.Navaneeth How to use google | Ask smart questions