Retrieving Telnet Client IP Address

Discussion to talk about software related topics only.
Post Reply
johnvan
Posts: 4
Joined: Thu May 05, 2022 7:26 am

Retrieving Telnet Client IP Address

Post by johnvan »

I've got Telnet working on my MODM7AE70 platform using the standard Netburner "Command" library functions. I'm interested in being able to know the IP address of the Telnet Client that logged into my board. I know that the basis for Telnet is a TCP connection (in this case on port 23). In my TCP server code when I call "accept()" I can specify a pointer to a temporary IP address and port where I can effectively read the Client IP address and port number.

Using "CmdListenOnTcpPort()" I eventually will get a File Descriptor (fp) but I don't have any direct access to the Clients IP address etc. I did some digging around in the source code in the "command.cpp" file and I can see the call to "accept()" with the IP address and port pointers set to NULL so that information is not in the Command[] structure.

Other than making up my own "RawAccept" function is there a way to get this information? I though about trying to get it by virture of having the File Descriptor but I don't see an easy way to query the socket data.

Not a critical thing, but something I'd like to be able to do.
User avatar
TomNB
Posts: 538
Joined: Tue May 10, 2016 8:22 am

Re: Retrieving Telnet Client IP Address

Post by TomNB »

Hello,

Have you looked at the Get Socket functions in the TCP API? https://www.netburner.com/NBDocs/Develo ... 3d68232ec9
johnvan
Posts: 4
Joined: Thu May 05, 2022 7:26 am

Re: Retrieving Telnet Client IP Address

Post by johnvan »

That is exactly what I was looking for! Thanks Tom.
Post Reply