daytimetcpcli.c [Problem]

This is a discussion on daytimetcpcli.c [Problem] within the C Programming forums, part of the General Programming Boards category; Hello, I have a problem with err_***.. The code is : Code: #include "unp.h" int main(int argc, char **argv) { ...

  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    2

    daytimetcpcli.c [Problem]

    Hello,
    I have a problem with err_***..

    The code is :
    Code:
    #include	"unp.h"
    
    
    int main(int argc, char **argv)
    {
    	int					sockfd, n;
    	char				recvline[MAXLINE + 1];
    	struct sockaddr_in	servaddr;
    
    	if (argc != 2)
    		err_quit("usage: a.out <IPaddress>");
    
    	if ( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) < 0)
    		err_sys("socket error");
    
    	bzero(&servaddr, sizeof(servaddr));
    	servaddr.sin_family = AF_INET;
    	servaddr.sin_port   = htons(13);	/* daytime server */
    	if (inet_pton(AF_INET, argv[1], &servaddr.sin_addr) <= 0)
    		err_quit("inet_pton error for %s", argv[1]);
    
    	if (connect(sockfd, (SA *) &servaddr, sizeof(servaddr)) < 0)
    		err_sys("connect error");
    
    	while ( (n = read(sockfd, recvline, MAXLINE)) > 0) {
    		recvline[n] = 0;	/* null terminate */
    		if (fputs(recvline, stdout) == EOF)
    			err_sys("fputs error");
    	}
    	if (n < 0)
    		err_sys("read error");
    
    	exit(0);
    }
    and the unp.h is : http://wklej.org/id/53340/

    and the problems are :
    daytimetcpcli.c.text+0x35): undefined reference to `err_quit'
    daytimetcpcli.c.text+0x6c): undefined reference to `err_sys'
    daytimetcpcli.c.text+0xd9): undefined reference to `err_quit'
    daytimetcpcli.c.text+0x106): undefined reference to `err_sys'
    daytimetcpcli.c.text+0x13e): undefined reference to `err_sys'
    daytimetcpcli.c.text+0x182): undefined reference to `err_sys'
    please tell me how I must do this

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Those error functions are in a libary somewhere. Someone else asked the question about 6 years back here: http://forums.devshed.com/c-programm...p-h-59962.html and appears to have got a success from the answers.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Feb 2009
    Posts
    2
    please write my what I must do.. I am doing that but the problems are still

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by kjiu View Post
    please write my what I must do.. I am doing that but the problems are still
    Did you look at the link? If so, what particular bits did you NOT understand? [Note, I have no direct knowledge of how to fix the problem - but the problem appears to have several solutions on the 'Net according to Google - I just posted a link to the first one].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 06-05-2009, 05:57 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21