04-25-2008
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);
}
7 More Discussions You Might Find Interesting
1. Programming
how does exec() do it? on successful call of exec() family of functions, they never return...
how to i emulate that.
assume the standard example,
execl("/bin/ls","ls",NULL);
now this would never return.
i m trying to emulate exec()'s never to return feature...
#include<unistd.h>... (4 Replies)
Discussion started by: c_d
4 Replies
2. Solaris
Had to reboot over 30 servers out of 70 or so during out of family code load. Still searching but may all have VxVM 3.5 in common. Our last window had similar outcome but on HPUX. I think it has to do with time outs and volume manager is offlining the devices. This just started happening. Anyone... (0 Replies)
Discussion started by: GaryP
0 Replies
3. UNIX for Dummies Questions & Answers
hello
is there a family tree, or words that would illustrate the family tree of,
Unix -> Linux
As i would understand Unix, it is a OS.
And Linux is a ?, is Linux a OS or a sub structure inside of the Unix OS ?.
Have you ever seen one of those family tree`s where ma and pa are shown at... (3 Replies)
Discussion started by: cowLips
3 Replies
4. Programming
Hi,
I am studying exec family of functions.Its man page says,it replaces the current process image with a new process image. If it replaces the binary,then after returning back,how does it get the previous parameters of the process which called exec?As replacing process image means replacing all... (1 Reply)
Discussion started by: Radha.Krishna
1 Replies
5. UNIX for Dummies Questions & Answers
Hi,
I am studying exec family of functions.Its man page says,it replaces the current process image with a new process image. If it replaces the binary,then after returning back,how does it get the previous parameters of the process which called exec?As replacing process image means replacing... (5 Replies)
Discussion started by: Radha.Krishna
5 Replies
6. AIX
Folks,
Again a very silly question :D Could someone tell me, how to determine the power family(540, 520, 575, 595 etc) just by looking into the model # info from prtconf/lsconf o/p of the lpar?
I dont want run a search on any search engine to find out the power family or hit IBM website to... (3 Replies)
Discussion started by: thisissouvik
3 Replies
7. Programming
# Erroneous question, so can be removed. (0 Replies)
Discussion started by: beginnerboy
0 Replies
LEARN ABOUT ULTRIX
rpc_use_family_wk
rpc_use_family_wk(3ncs) rpc_use_family_wk(3ncs)
Name
rpc_use_family_wk - create a socket with a well-known port for a remote procedure call (RPC) server (server only)
Syntax
#include <idl/c/rpc.h>
void rpc_$use_family_wk(family, ifspec, sockaddr, slength, status)
unsigned long family;
rpc_$if_spec_t *ifspec;
socket_$addr_t *sockaddr;
unsigned long *slength;
status_$t *status;
Arguments
family The address family of the socket to be created. This value corresponds to the communications protocol used to access the
socket and determines how the sockaddr is expressed. The value must be one of socket_$unspec or socket_$internet.
ifspec The interface that will be registered by the server. Typically, this parameter is the interface if_spec generated by the
NIDL compiler from the interface definition; the well-known port is specified as an interface attribute.
sockaddr The socket address of the socket on which the server will listen.
slength The length, in bytes, of sockaddr.
status The completion status. If the completion status returned in is equal to status_$ok , then the routine that supplied it was
successful.
Description
The routine creates a socket that uses the port specified through the if_spec parameter. Use this routine to create a socket only if a
server must listen on a particular well-known port. Otherwise, use
A server listens on one socket per address family, regardless of how many interfaces that it exports. Therefore, servers that use well-
known ports should make this call once per supported address family.
Examples
The following statement creates the well-known socket identified by for an array processor server:
rpc_$use_family_wk (socket_$internet, &matrix$if_spec,
&sockaddr, &slen, &status);
Diagnostics
This section lists status codes for errors returned by this routine in
rpc_$cant_create_sock
The RPC runtime library was unable to create a socket.
rpc_$not_in_call An internal error.
rpc_$proto_error An internal protocol error.
rpc_$too_many_sockets
The server is trying to use more than the maximum number of sockets that is allowed; it has called or too many times.
rpc_$bad_pkt The server or client has received an ill-formed packet.
rpc_$addr_in_use The address and port specified in an routine are already in use. This is caused by multiple calls to with the same
well-known port.
Files
See Also
intro(3ncs), rpc_use_family(3ncs)
rpc_use_family_wk(3ncs)