Solved

Getting remote socket within inetd server

Posted on 1997-08-29
1
279 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
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Let’s list some of the technologies that enable smooth teleworking. 
Even if you have implemented a Mobile Device Management solution company wide, it is a good idea to make sure you are taking into account all of the major risks to your electronic protected health information (ePHI).
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

770 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