Date: Wed, 20 Nov 1996 22:26:01 -0200 From: compland@ism.com.br (Helio Coelho Jr. - CompuLand Informatica) To: hackers@freebsd.org Cc: zyang01@fiu.edu Subject: socket.h Message-ID: <199611210026.WAA15690@unix1.ism.com.br>
next in thread | raw e-mail | index | archive | help
Hi: Sorry posting here. I'm not member of the developers group but I have a question that maybe someone from this list can help me ! The problem is that I'm tring to port an irc gateway to WWW, written by Zhong Yang in C. I'm stuck in the following: this is from /include/sys/socket.h struct sockaddr { u_char sa_len; /* total length */ u_char sa_family; /* address family */ char sa_data[14]; /* actually longer; address value */ this is from /include/netinet/in.h struct sockaddr_in { u_char sin_len; u_char sin_family; u_short sin_port; struct in_addr sin_addr; char sin_zero[8]; And here, the problem. That's actually part of the code of the gateway: struct sockaddr_in SocketInetAddr; ^^^^^^^^^^^ SocketInetAddr.sin_port = htons(Port); SocketDescriptor = socket(AF_INET, SOCK_STREAM, 6); if (SocketDescriptor < 0) { perror("socket"); return (-1); } if (connect(SocketDescriptor, ( char *) &SocketInetAddr, sizeof(SocketInetAddr)) < 0) ^^^^^^^^^^^^^^^^^^^^^^^^^ RETURN_SUCCESS=1; else RETURN_SUCCESS=0; The above call to CONNECT reports an error because the connect function expects, in the second field, the use of sockaddr. But in the program, the call is for sockaddr_in. I don't know if in AIX or hpux this structures are the same, but I know that it works there ! Anyone has an idea how can I change this piece of code to put it to work in FreeBSD ? Thanks a lot! Sorry for the off_topic question! Regards, Helio.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199611210026.WAA15690>