Butuh bantuan nich. udah kepentok plus bingung ..
saya punya program kecil tentang pthread.

dan saya kompile :
  $ cc -o recv.o recv.c 
dan muncul pesen error semacam ini 

tmp/ccr0O7x7.o: In function `main':
/tmp/ccr0O7x7.o(.text+0xe3): undefined reference to `pthread_create'
collect2: ld returned 1 exit status


Ada saran dimana saya harus membetulkanya ??




------------------ lampiran recv.c ---------
#include <sys/socket.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <pthread.h>

static int sockfd;
void *recvT(void *);

/*C{
int pthread_create(pthread_t * tid, const pthread_attr_t * attr,
        void * ( *start_routine )( void * ), void * arg);
}*/

int main(int argc, char **argv)
{
        int status, status1;
        struct sockaddr_in addr;
        pthread_t tid;
        int n;

        sockfd = socket(AF_INET, SOCK_DGRAM, 0);
        if (sockfd > -1)
           printf("socket success %d \n",sockfd);
        else {
           printf("socket error %d \n",sockfd);
           return 0;
        }

        addr.sin_family = AF_INET;
        addr.sin_addr.s_addr = htonl(INADDR_ANY);
        addr.sin_port = htons(220);
        
        status = bind(sockfd, (struct sockaddr *)&addr, sizeof(addr));
        if (status > -1)
           printf("bind success %d \n",status);
        else {
           printf("bind error %d \n",status);
           return 0;
        }
        
/*      pid = fork();
        if (pid >= 0) {
           printf("fork success \n");
           recvT();
        } else {
           printf("fork error \n");
           return(0);
        }
*/
        n = pthread_create(&tid, NULL, recvT, NULL);
        if (n >= -1){
           printf("thread success \n");
           return(0);
        }
}

void *recvT(void *pass)
{
        int status1;
        struct sockaddr_in remote;
        char tempBuff[60];

        for( ; ; ) {
           status1 = recvfrom(sockfd, tempBuff, 60, 0, (struct sockaddr *) &remote, 
(int *) sizeof(remote));
           if (status1 >= -1){
              printf("recv success %d \n",status1);
              printf("%s \n",tempBuff);
              tempBuff[status1] = '\0';
              sprintf(tempBuff,"from %s",inet_ntoa(remote.sin_addr));
              printf("%s \n",tempBuff); 
           } else {
              printf("recv error %d \n",status1);
              close(sockfd);
              return(0);
           }
        }
}





--------------------------------------------------------------------------------
Utk berhenti langganan, kirim email ke [EMAIL PROTECTED]
Informasi arsip di http://www.linux.or.id/milis.php3
Pengelola dapat dihubungi lewat [EMAIL PROTECTED]

Kirim email ke