|
在TCP服务程序中我想使用pthread_create(&thread[no],NULL,thrd_func,(void*)sockfd)传递sockfd这个整形数据该如何传递?
void *thrd_func(void *sockfd)
{
int client_fd,send_len;
char buf[BUFFER_SIZE];
struct sockaddr_in server_sockaddr,client_sockaddr;
int sin_size=sizeof(struct sockaddr_in),recvbytes;
while(1)
{
client_fd=accept(sockfd,(struct sockaddr*)&client_sockaddr,&sin_size);
memset(buf,0,strlen(buf));
recv(client_fd,buf,BUFFER_SIZE,0);
printf("recive a message: %s\n",buf);
strcpy(buf,test_snd_msg);
send_len=send(client_fd , buf, strlen(buf), 0);
if(send_len < 0)
{
printf("send error fd: %d !\n ", client_fd);
return 0;
}
}
close(sockfd);
exit(0);
}
我上面写的程序执行时总是有个警告server1.c:30: warning: passing argument 1 of ‘accept’ makes integer from pointer without a cast
server1.c:45: warning: passing argument 1 of ‘close’ makes integer from pointer without a cast
请各位大牛帮小弟解决一下这个问题哈 |
|