컴파일 할때 Undefined symbol "inet_ntoa" 에러메세
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <client.h>
#include <string.h>
#define MYPORT 4950
#define MAXBUFLEN 100
int main()
{
int sockfd;
struct sockaddr_in their_addr, my_addr; /* connector's address information */
int addr_len, numbytes;
char buf[MAXBUFLEN];
unsigned int yes;
char inet_ntoa(struct sin_addr in); /* binary to dotted decimal */
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
perror("socket");
exit(1);
}
bzero((char*)&my_addr,sizeof(my_addr));
my_addr.sin_family = AF_INET;
my_addr.sin_addr.s_addr = htonl(INADDR_ANY);
my_addr.sin_port = htons(MYPORT);
if (bind(sockfd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)) == -1) {
perror("bind");
exit(1);
}
addr_len = sizeof(struct sockaddr);
if ((numbytes=recvfrom(sockfd, buf, MAXBUFLEN, 0, (struct sockaddr *)&their_addr, &addr_len)) == -1) {
perror("recvfrom");
exit(1);
}
printf("got packet from %s\n",inet_ntoa(their_addr.sin_addr));
printf("packet is %d bytes long\n",numbytes);
buf[numbytes] = '\0';
printf("packet contains \"%s\"\n",buf);
close(sockfd);
}
#define inet_ntoa 해서 문제 해결했습니다. ^^;
#define inet_ntoa 해서 문제 해결했습니다. ^^;
Re: 컴파일 할때 Undefined symbol "inet_ntoa" 에러
윗 부분이 잘못되었죠?
========================================
* The truth will set you free.
댓글 달기