Solved

Getting remote socket within inetd server

Posted on 1997-08-29
1
289 Views
Last Modified: 2013-12-23
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
Comment
Question by:dogma
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
bkc earned 100 total points
ID: 1582354
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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PRTG Network Monitor lets you monitor your bandwidth usage, so you know who is using up your bandwidth, and what they're using it for.
This program is used to assist in finding and resolving common problems with wireless connections.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month7 days, 16 hours left to enroll

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question