当前位置: 技术问答>linux和unix
高手来看看,这个函数死活运行不成功.谢谢指导.
来源: 互联网 发布时间:2015-03-25
本文导语: struct sockaddr_in Serveraddr ; if ( ( m_iSocket = socket(AF_INET,SOCK_STREAM,0)) == -1 ) { printf(" Create Server Socket is Errorn") ; return 1 ; } bzero( & Serveraddr, sizeof(Serveraddr) ) ; Serveraddr.sin_family = AF_INET ; Serveraddr.sin_port = hto...
struct sockaddr_in Serveraddr ;
if ( ( m_iSocket = socket(AF_INET,SOCK_STREAM,0)) == -1 )
{
printf(" Create Server Socket is Errorn") ;
return 1 ;
}
bzero( & Serveraddr, sizeof(Serveraddr) ) ;
Serveraddr.sin_family = AF_INET ;
Serveraddr.sin_port = htons( 1023 ) ;
Serveraddr.sin_addr.s_addr = htonl(INADDR_ANY) ;
// 上边都运行成功了,就是下边这个函数不知道为什么,他老是打印那一句话.
if ( bind(m_iSocket , (struct sockaddr *) &Serveraddr,sizeof(Serveraddr))
if ( ( m_iSocket = socket(AF_INET,SOCK_STREAM,0)) == -1 )
{
printf(" Create Server Socket is Errorn") ;
return 1 ;
}
bzero( & Serveraddr, sizeof(Serveraddr) ) ;
Serveraddr.sin_family = AF_INET ;
Serveraddr.sin_port = htons( 1023 ) ;
Serveraddr.sin_addr.s_addr = htonl(INADDR_ANY) ;
// 上边都运行成功了,就是下边这个函数不知道为什么,他老是打印那一句话.
if ( bind(m_iSocket , (struct sockaddr *) &Serveraddr,sizeof(Serveraddr))