- 论坛徽章:
- 0
|
我用gcc编译正常,并且运行也OK,但是用g++编译就报错:
错误1:
cannot convert `int *' to `socklen_t *' for argument `3' to `accept (int, sockaddr *, socklen_t *)'
if((fd=accept(sockfd,(struct sockaddr*)&their_addr,&sin_size))==-1)
{ //error
}
错误2:
`inet_ntoa' undeclared (first use this function)
printf("Server: got connection from %s\n",inet_ntoa(their_addr.sin_addr));
错误3:
`close' undeclared (first use this function)
close(fd);
这个程序就是www.fangqiang.com里面的例程。我郁闷ing.
难道g++用的accept原型不一样?然后inet_ntoa和close函数也没有了?
我该用什么代替啊?
谢谢大家先。 |
|