sizak
asked on
EAFNOSUPPORT porting from freebsd to linux
Alright so i have this application that I have just finished porting to linux.. mainly little things like using namespace std and such to make it happy.. anyway whenthe program runs.. it returns this..
EAFNOSUPPORT
the code of this program is huge. but anywhere here is the jistof things..
struct sockaddr_in * addr;
*somewhere up here it gets a ip and puts everything together in addr*
i was looking through the code and i see alot of
cli_addr.sin_family = AF_INET;
or srv_addr.sin_family = AF_INET;
struct sockaddr_in * mserv_addr;
mserv_addr=addr;
sock = socket(AF_INET,SOCK_STREAM ,0); // set the socket
if (connect(sock,(struct sockaddr *) mserv_addr,sizeof(struct sockaddr_in)) == 0) {
ndelay_off(sock);
free(t_str);
t_str = NULL;
return true;
}
^^^^ after that statement there is a case statement which checks errno and spits out the error..
there anything i need to change or you guys can think of?
EAFNOSUPPORT
the code of this program is huge. but anywhere here is the jistof things..
struct sockaddr_in * addr;
*somewhere up here it gets a ip and puts everything together in addr*
i was looking through the code and i see alot of
cli_addr.sin_family = AF_INET;
or srv_addr.sin_family = AF_INET;
struct sockaddr_in * mserv_addr;
mserv_addr=addr;
sock = socket(AF_INET,SOCK_STREAM
if (connect(sock,(struct sockaddr *) mserv_addr,sizeof(struct sockaddr_in)) == 0) {
ndelay_off(sock);
free(t_str);
t_str = NULL;
return true;
}
^^^^ after that statement there is a case statement which checks errno and spits out the error..
there anything i need to change or you guys can think of?
ASKER
shortly after it does it does check..
sock = socket(AF_INET,SOCK_STREAM ,0); // set the socket
if (sock == -1) {
tracer->print(T_SMTP,TR_ER ROR,3,"Cre ate socket failure.");
other stuff is here too...
so it does create the socket.
sock = socket(AF_INET,SOCK_STREAM
if (sock == -1) {
tracer->print(T_SMTP,TR_ER
other stuff is here too...
so it does create the socket.
The only thing I can think of right now is to double check sin_family pointed to by mserv_addr right before the call to connect to make sure it really is AF_INET
>mserv_addr=addr;
what are the values in addr ?
1. try printing all members of the struct before the connect call
2. run your program through a debugger to be double sure
what are the values in addr ?
1. try printing all members of the struct before the connect call
2. run your program through a debugger to be double sure
ASKER
last night i added.
mserv_addr->sin_family=AF_ INET;
compiled.. error went away.. but not when it runs I believe it does make its connection.. but doesn't know wat to do from there. I'm assuming the way they talk together didn't port over :-/
mserv_addr->sin_family=AF_
compiled.. error went away.. but not when it runs I believe it does make its connection.. but doesn't know wat to do from there. I'm assuming the way they talk together didn't port over :-/
Given that connect() is now returning a 0, is your read giving a bad return or just not getting any data?
ASKER
connect() isn't connecting.
if (connect(sock,(struct sockaddr *) mserv_addr,sizeof(struct sockaddr_in)) == 0) {
ndelay_off(sock);
sprintf(t_str,"COnnection Made!");
tracer->print(T_SENDER,TR_ NOTIFY,1,t _str);
free(t_str);
t_str = NULL;
return true;
} else {
sprintf(t_str,"Not connected");
tracer->print(T_SENDER,TR_ NOTIFY,1,t _str);
}
I get the not connected in my logs.
if (connect(sock,(struct sockaddr *) mserv_addr,sizeof(struct sockaddr_in)) == 0) {
ndelay_off(sock);
sprintf(t_str,"COnnection Made!");
tracer->print(T_SENDER,TR_
free(t_str);
t_str = NULL;
return true;
} else {
sprintf(t_str,"Not connected");
tracer->print(T_SENDER,TR_
}
I get the not connected in my logs.
ASKER
I added a
sprintf(t_str,"Errorno: %d",errno);
tracer->print(T_SENDER,TR_ NOTIFY,1,t _str);
after the not connect so i saw the error in the logs.
and it came back with 115..
perror 115 says..
Error code 115: Operation now in progress
? i'm confused how can it be inprogress if it fails on connect?
sprintf(t_str,"Errorno: %d",errno);
tracer->print(T_SENDER,TR_
after the not connect so i saw the error in the logs.
and it came back with 115..
perror 115 says..
Error code 115: Operation now in progress
? i'm confused how can it be inprogress if it fails on connect?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry about the cross-post (and not listing all the errors at that).
A return of EINPROGRESS says that the socket is non-blocking (i.e., asynchronous) and that the connection hasn't.
All the man pages say:
=====
The socket is non-blocking and the connection cannot be completed immediately. It is possible to select (2) or poll (2) for completion by selecting the socket for writing. After select indicates writability, use getsockopt (2) to read the SO_ERROR option at level SOL_SOCKET to determine whether connect completed successfully ( SO_ERROR is zero) or unsuccessfully ( SO_ERROR is one of the usual error codes listed above, explaining the reason for the failure).
=====
A return of EINPROGRESS says that the socket is non-blocking (i.e., asynchronous) and that the connection hasn't.
All the man pages say:
=====
The socket is non-blocking and the connection cannot be completed immediately. It is possible to select (2) or poll (2) for completion by selecting the socket for writing. After select indicates writability, use getsockopt (2) to read the SO_ERROR option at level SOL_SOCKET to determine whether connect completed successfully ( SO_ERROR is zero) or unsuccessfully ( SO_ERROR is one of the usual error codes listed above, explaining the reason for the failure).
=====
sock = socket(AF_INET,SOCK_STREAM
if (sock==-1) oopsie...