【正文】
/* well... better receive it */ text = (char*)malloc(sizeof(char) * 1024)。 while(1) { int nbyte = recv(sock, text, 1024, 0)。 if(nbyte 1024) break。 } free(text)。 /* close the connection */ close(sock)。 } } int main(int argc, char* argv[]) { /* initialize */ pthread_t* arr_pid = (pthread_t*)malloc(sizeof(pthread_t) * THREAD_NUM)。 pthread_mutex_init(amp。sock_mutex, NULL)。 pthread_cond_init(amp。sock_cond, NULL)。 /* create all the thread */ int i。 第 16 頁 for(i = 0。 i THREAD_NUM。 i++) pthread_create(amp。arr_pid[i], NULL, sock_thread, NULL)。 while(1) { /* sleep for a while to let one of the thread to go */ usleep(200)。 pthread_cond_signal(amp。sock_cond)。 } /* clean up all the thread */ for(i = 0。 i THREAD_NUM。 i++) pthread_join(arr_pid[i], NULL)。 return 0。 參考文獻(xiàn): 百度百科,易語言基礎(chǔ)。 第 17 頁