accept() 函数的问题
编译环境:Target:i486-linux-gnuConfiguredwith:../src/configure-v--with-pkgversion='Ubuntu4...
编译环境:
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.3-4ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)
源码:
int sin_size = sizeof(struct sockaddr_in);
if(sockacc = accept(sockfd,(struct sockaddr*)&client,&sin_size) != 0){
perror("failt to accept!");
continue ;
}
编译结果:
server.cpp: In function ‘int main(int, char**)’:
server.cpp:72: error: invalid conversion from ‘int*’ to ‘socklen_t*’
server.cpp:72: error: initializing argument 3 of ‘int accept(int, sockaddr*, socklen_t*)’
为何出现这个问题??? 展开
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.3-4ubuntu5' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)
源码:
int sin_size = sizeof(struct sockaddr_in);
if(sockacc = accept(sockfd,(struct sockaddr*)&client,&sin_size) != 0){
perror("failt to accept!");
continue ;
}
编译结果:
server.cpp: In function ‘int main(int, char**)’:
server.cpp:72: error: invalid conversion from ‘int*’ to ‘socklen_t*’
server.cpp:72: error: initializing argument 3 of ‘int accept(int, sockaddr*, socklen_t*)’
为何出现这个问题??? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询