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