Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. UdpClient Error : Only one usage of each socket address (protocol/network address/port) is normally permitted

UdpClient Error : Only one usage of each socket address (protocol/network address/port) is normally permitted

Scheduled Pinned Locked Moved C#
helpquestionsysadmin
3 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Z Offline
    Z Offline
    zafersavas
    wrote on last edited by
    #1

    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

    L N 2 Replies Last reply
    0
    • Z zafersavas

      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

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      The error comes only if you press button1 2 times. If you press button1, button2, then button1 again, it's ok.

      1 Reply Last reply
      0
      • Z zafersavas

        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

        N Offline
        N Offline
        N a v a n e e t h
        wrote on last edited by
        #3

        Why 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, call Connect() method to connect the socket.

        Navaneeth How to use google | Ask smart questions

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups