Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 295
  • Last Modified:

Getting remote socket within inetd server

I have written a couple of servers that work with inetd and I need to be able to get the IP of the connected host.

So, how do I get the remote socket from the stdin handle?
0
dogma
Asked:
dogma
1 Solution
 
bkcCommented:
If you are using the FILE * stdin, you can get the file handle using the fileno() function.

struct sockaddr_in sin;
int slen = sizeof(sin);
int rc = getpeername(fileno(stdin), &sin, &slen);

I suspect that the result from fileno(stdin) is 0, since stdin is
always handle 0 and inetd dups its socket as handle 0 before spawning your server.

0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now