Solved

Getting remote socket within inetd server

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Data center, now-a-days, is referred as the home of all the advanced technologies. In-fact, most of the businesses are now establishing their entire organizational structure around the IT capabilities.
In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
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…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

867 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now