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 can I find out what service is used by a winsock connection?

How can I find out what service is used by a winsock connection?

Scheduled Pinned Locked Moved C / C++ / MFC
questionsysadminhelptutorial
5 Posts 4 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
    Zdenek Navratil
    wrote on last edited by
    #1

    I have a winsocket server listening on a given port, say 2000. Is there a way how to find out what service (eg. telnet) is used by a particular client when it connects to the server? I tried getpeername() on a connected socket to get sockaddr_in structure filled and then I called getservbyport() with sin_port parameter from sockaddr_in, but with no success. I've got WSANO_DATA (Valid name, no data record of requested type) error. I'd really appreciate any insight recommendation Zdenek

    Z C 2 Replies Last reply
    0
    • Z Zdenek Navratil

      I have a winsocket server listening on a given port, say 2000. Is there a way how to find out what service (eg. telnet) is used by a particular client when it connects to the server? I tried getpeername() on a connected socket to get sockaddr_in structure filled and then I called getservbyport() with sin_port parameter from sockaddr_in, but with no success. I've got WSANO_DATA (Valid name, no data record of requested type) error. I'd really appreciate any insight recommendation Zdenek

      Z Offline
      Z Offline
      Zdeslav Vojkovic
      wrote on last edited by
      #2

      Here[^] you can find a tool (and source code) which retrieves information about each connection

      Z 1 Reply Last reply
      0
      • Z Zdeslav Vojkovic

        Here[^] you can find a tool (and source code) which retrieves information about each connection

        Z Offline
        Z Offline
        Zdenek Navratil
        wrote on last edited by
        #3

        Nope. I've downloaded both the source of netstatp and TcpView utility from a recommended site. There's no information there how to find out a service the client is using. Even a TcpView only guesses the service from a well known port number. Regards, Zdenek

        A 1 Reply Last reply
        0
        • Z Zdenek Navratil

          Nope. I've downloaded both the source of netstatp and TcpView utility from a recommended site. There's no information there how to find out a service the client is using. Even a TcpView only guesses the service from a well known port number. Regards, Zdenek

          A Offline
          A Offline
          Alexander M
          wrote on last edited by
          #4

          You cannot guess! The only way would be to create a filter to listen to the connection and to check the service that way. But normally it is not possible! Don't try it, just do it! ;-)

          1 Reply Last reply
          0
          • Z Zdenek Navratil

            I have a winsocket server listening on a given port, say 2000. Is there a way how to find out what service (eg. telnet) is used by a particular client when it connects to the server? I tried getpeername() on a connected socket to get sockaddr_in structure filled and then I called getservbyport() with sin_port parameter from sockaddr_in, but with no success. I've got WSANO_DATA (Valid name, no data record of requested type) error. I'd really appreciate any insight recommendation Zdenek

            C Offline
            C Offline
            cmk
            wrote on last edited by
            #5

            You're question doesn't make sense. Both the client and service code must 'speak' the same service protocol (e.g. telnet). Well know port numbers are associated with specific services so that it is easier to write client code (you only need the server name and can assume the expected service is listening on the appropriate port). If you configure your service to listen to another port instead of, or as well as, the well known port number then you know that any client that connects to that port MUST speak that protocol if any meaningfull communication is to take place. e.g. If you have a ftp server that you set up to listen to port 2000 and have a telnet client try to connect to port 2000 nothing will happen - they speak different protocols. In short, the server dictates the protocol the client must use. ...cmk Save the whales - collect the whole set

            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