LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   inet_addr compile problem (https://www.linuxquestions.org/questions/linux-networking-3/inet_addr-compile-problem-658104/)

MrUmunhum 07-24-2008 10:17 PM

inet_addr compile problem
 
Hi group,

I'm stumped by this new problem.

My code:
in .h:

struct Peer {
char Name[25]; // Name used to ID Peer.
char IP[20]; // IP Address of target Peer.
int Port; // Connect on this port.
struct sockaddr_in Addr; // Socket Addr
int Socket; // Socket number

struct Peer* Next; }; // Next Peer's control block in list
in .c:
Peer->Addr.sin_addr.s_addr = inet_addr( "64.124.13.3" );
in inet.h:

/* Convert Internet host address from numbers-and-dots notation in CP
into binary data in network byte order. */
extern in_addr_t inet_addr (__const char *__cp) __THROW;
error at complie time:
socket.c: In function ‘Call_Peer’:
socket.c:142: error: incompatible implicit declaration of function ‘inet_addr’
/usr/include/arpa/inet.h:35: error: previous implicit declaration of ‘inet_addr’ was here
make: *** [socket.o] Error 1
What stupid thing did I do wrong??:(

MrUmunhum 07-25-2008 02:53 PM

I fixed it by adding #include <arpa/inet.h> to the main.h file.


All times are GMT -5. The time now is 01:01 AM.