Google Answers Logo
View Question
 
Q: To get the IP of a machine that connect to my machine for the daemon at Unix. ( No Answer,   0 Comments )
Question  
Subject: To get the IP of a machine that connect to my machine for the daemon at Unix.
Category: Computers > Programming
Asked by: adamhsu-ga
List Price: $20.00
Posted: 11 Sep 2003 20:25 PDT
Expires: 12 Sep 2003 01:12 PDT
Question ID: 254870
I have write some socket program at Unix(sun-solaris).
With the socket-api "getpeername",
I can get the IP of a machine that connect to my machine.
Now,I must write a daemon program at Unix(sun-solaris).
I can get the information that the client send to my machine.
But,how can I get the IP that connect to my machine at my daemon-program???
I provide an sample code,I wish my answer can write some code in my program.
Let me know how can I get the IP of a machine that connect to my machine 
and let me see and check the answer is correct.
Thanks......
// daemon sample code
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
int main(void)
{
	char ap_command[1024];
	memset(ap_command,'\0',1024);	
	setvbuf(stdout,NULL,_IOLBF,0);	
	///////////////////////////////////////////
	// How can I get the IP-address of a machine 
	// that connect to my machine.	
	///////////////////////////////////////////		
	while(fgets(ap_command,sizeof(ap_command),stdin) != NULL)
	{
		printf("ECHO:%s\n\r",ap_command);
		memset(ap_command,'\0',1024);
	}
	return(0);
}
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy