![]() |
|
|
|||||||
| Home | Forums | Register | Rules & FAQ | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| OS X (Apple) OS X is a line of Unix-based graphical operating systems developed, marketed, and sold by Apple. |
Other UNIX.COM Threads You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| AIX supported graphics cards | HNelson | AIX | 2 | 01-24-2008 05:55 AM |
| Speaking Hangman is fun for the whole family | iBot | UNIX and Linux RSS News | 0 | 01-04-2008 01:20 PM |
| Need Help- Does MENDELTRON ESQUIRE is supported by AIX 5.3 | balasubramaniam | AIX | 1 | 04-12-2006 01:56 PM |
| RMB supported? | huhuloa | HP-UX | 1 | 09-27-2005 10:07 AM |
![]() |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Address family not supported by protocol family
Hi,
I compiled with no error a C program, than I tryed to execute it and than I get this error: connessione al server fallita: Address family not supported by protocol family What does it mean? Why I get this error only on Mac os x while on Ubuntu the program works? The code is: /* * EsameClient.c * */ #include <stdlib.h> #include <ctype.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #define NR 3 #define MAXLENGTH 80 #define SERVER_PORT 1313 int main (unsigned argc, char **argv) { int sockfd; struct sockaddr_in server={AF_INET,htons(SERVER_PORT),INADDR_ANY}; int i=0,len; char buf[MAXLENGTH],c; int buffer[NR], stato; /* Controllo Parametri Passati da Terminale */ if(argc != 4) // argv[1] -> argv[3] sono le risorse { perror("Chiamata corretta del programma:\nnome-programma <risorsa1> <risorsa2> <risorsa3> \n<risorsai> deve essere un intero positivo"); exit(1); } /* impostazione del transport end point */ if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) { perror("chiamata alla system call socket fallita"); exit(1); } /* connessione al server */ if(connect(sockfd,(struct sockaddr *)&server,sizeof server)==-1) { perror("connessione al server fallita"); exit(2); } /* ricezione e stampa a video del messaggio di benvenuto del server */ if(recv(sockfd,buf,27,0)>0) { buf[27]='\0'; printf("%s",buf); } else { perror("Connessione al server interrotta"); exit(3); } /* acquisizione della stringa da standard input */ /* while((c=getchar())!='\n' && i<MAXLENGTH) buf[i++]=c; buf[i]='\0'; len=strlen(buf); */ // Imposta buffer e len for(i=0; i<NR;i++) buffer[i]=argv[i+1]; len=sizeof(buffer); // size?? o # = 3///////////////////////////////////////////////////// /* invio e ricezione della stringa */ if(send(sockfd,buffer,len,0)==-1) // Se send ritorna -1 = errore { perror("Errore nell'invio della richiesta risorse al server"); exit(4); } if(recv(sockfd,&stato,len,0)>0) { printf("%d\n",stato); } else { perror("Connessione al server interrotta"); exit(3); } /* chiusura della connessione */ close(sockfd); } |
| Forum Sponsor | ||
|
|
|
|||
|
Google suggests Ettercap :: View topic - ettercap & MacOS X (10.2.6) not finding other machines..
Quote:
|
|
|||
|
One of the problems with your code is that you are using IP address INADDR_ANY. This allows your program to work without knowing the IP address of the system it is running on, or, in the case of a system with multiple network interfaces, it allows your server to receive packets destined to any of the interfaces. However there are issues with using INADDR_ANY. Do a Google search on INADDR_ANY for more information.
I suggest that you bind to a specific server address. |
|||
| Google UNIX.COM |