struct sockaddr
Koxaras Aris
koxaras at ceid.upatras.gr
Thu Nov 27 22:55:41 EET 1997
On Thu, 27 Nov 1997, Kostas Lialiambis wrote:
> Bre paidia, steilte ena mikro paradeigma toy getpeername(2) se C. As poyme
> dhladh oti exw ena int s me thn timh mias socket kai 8elw na na
> parw se string to ip address aytoy poy thn anoi3e. Oysiastika
> den mporesa na brw ti soi moprfh exei to sockaddr structure. An kapoios
> apla moy pei se poio header file einai 'h moy to grapsei edw 8anai to idio
> san na moy exei dwsei kai paradeigma.
> Kor.
san auto? valto sto inetd.conf kai kane telnet sto antistoixo
service:
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
void main() {
int num, c;
struct sockaddr_in s;
c = sizeof(struct sockaddr_in);
if ( (num=getpeername(0, (struct sockaddr *)&s, &c )) < 0 ) {
perror("getpeername()");
exit(-1);
}
printf("%s\n", inet_ntoa(s.sin_addr));
exit(0);
}
Seeya,
mastoras at hack.gr
--
====================================================================
Gia na mathete pos na xrisimopoiite ton majordomo, stilte e-mail
sto "majordomo at argos.hol.gr" me 1 grammi sto keimeno: help
Ta archives tis listas einai sto http://www.argos.hol.gr/lists
Gia opoiodipote problima stilte e-mail ston owner-linux-greek-users
====================================================================
More information about the Linux-greek-users
mailing list