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 / C++ / MFC
  4. How to get a port number bound to a given socket using function other than getsockname()

How to get a port number bound to a given socket using function other than getsockname()

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
10 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.
  • G Offline
    G Offline
    Gajendra Sharma
    wrote on last edited by
    #1

    Hello, Is there any way to get port number bound to a given socket using the socket descriptor. I dont want to use getsockname(). Thanks in advance.

    Gajendra

    _ 1 Reply Last reply
    0
    • G Gajendra Sharma

      Hello, Is there any way to get port number bound to a given socket using the socket descriptor. I dont want to use getsockname(). Thanks in advance.

      Gajendra

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      Why don't you want to use getsockname().

      «_Superman_» I love work. It gives me something to do between weekends.

      G 1 Reply Last reply
      0
      • _ _Superman_

        Why don't you want to use getsockname().

        «_Superman_» I love work. It gives me something to do between weekends.

        G Offline
        G Offline
        Gajendra Sharma
        wrote on last edited by
        #3

        Thanks for your response. the problem is getsockname() sometimes fails due the following microsoft issue: http://support.microsoft.com/kb/319952[^]

        Gajendra

        _ 1 Reply Last reply
        0
        • G Gajendra Sharma

          Thanks for your response. the problem is getsockname() sometimes fails due the following microsoft issue: http://support.microsoft.com/kb/319952[^]

          Gajendra

          _ Offline
          _ Offline
          _Superman_
          wrote on last edited by
          #4

          I think you should use it because the site also talk about the resolution for the failure.

          «_Superman_» I love work. It gives me something to do between weekends.

          G CPalliniC 2 Replies Last reply
          0
          • _ _Superman_

            I think you should use it because the site also talk about the resolution for the failure.

            «_Superman_» I love work. It gives me something to do between weekends.

            G Offline
            G Offline
            Gajendra Sharma
            wrote on last edited by
            #5

            I want to avoid the complexity associated with WSADuplicateSocket. I just want to pass the port number across processes, thats my only requirement. I need some mechanism through which i can get socket number in parent process and pass it to the child process as an argument. By parent process i mean process that invokes the second process, which i call the child process.

            Gajendra

            _ 1 Reply Last reply
            0
            • G Gajendra Sharma

              I want to avoid the complexity associated with WSADuplicateSocket. I just want to pass the port number across processes, thats my only requirement. I need some mechanism through which i can get socket number in parent process and pass it to the child process as an argument. By parent process i mean process that invokes the second process, which i call the child process.

              Gajendra

              _ Offline
              _ Offline
              _Superman_
              wrote on last edited by
              #6

              Don't duplicate the socket at all. Get the port number using the socket descriptor. And pass this port number to the child process as a command line argument.

              «_Superman_» I love work. It gives me something to do between weekends.

              G 1 Reply Last reply
              0
              • G Gajendra Sharma

                u mean using Get the port number using getsockname()?

                Gajendra

                _ Offline
                _ Offline
                _Superman_
                wrote on last edited by
                #7

                Yes, without duplicating the socket.

                «_Superman_» I love work. It gives me something to do between weekends.

                G 1 Reply Last reply
                0
                • _ _Superman_

                  Don't duplicate the socket at all. Get the port number using the socket descriptor. And pass this port number to the child process as a command line argument.

                  «_Superman_» I love work. It gives me something to do between weekends.

                  G Offline
                  G Offline
                  Gajendra Sharma
                  wrote on last edited by
                  #8

                  u mean using Get the port number using getsockname()?

                  Gajendra

                  _ 1 Reply Last reply
                  0
                  • _ _Superman_

                    I think you should use it because the site also talk about the resolution for the failure.

                    «_Superman_» I love work. It gives me something to do between weekends.

                    CPalliniC Offline
                    CPalliniC Offline
                    CPallini
                    wrote on last edited by
                    #9

                    5. :-D

                    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                    [My articles]

                    In testa che avete, signor di Ceprano?

                    1 Reply Last reply
                    0
                    • _ _Superman_

                      Yes, without duplicating the socket.

                      «_Superman_» I love work. It gives me something to do between weekends.

                      G Offline
                      G Offline
                      Gajendra Sharma
                      wrote on last edited by
                      #10

                      Thanks for your answer!!!

                      Gajendra

                      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