connect无法连接
我写了一个客户端,如下#include<PROCESS.H>
#include<windows.h>
#include<winsock.h>
#include<sys/types.h>
#include<fcntl.h>
#include<wsipx.h>
#include<stdio.h>
#include<iostream.h>
#define SERV_TCP_PORT 600
int main()
{
int sockfd,a;
int nRet;
char szBuf[1024];
struct sockaddr_in serv_addr;
WORD wVersionRequested=MAKEWORD(1,1);
WSADATA wsaData;
if(WSAStartup(wVersionRequested,&wsaData)){
printf("WSAStartup failed %s\n", WSAGetLastError());
return -1;
}
if((sockfd=socket(AF_INET,SOCK_STREAM,0))<0){
printf("server:can't open stream socker\n");
}
else printf("sockfd=%d\n",sockfd);
memset((char *)&serv_addr,0,sizeof(struct sockaddr_in));
serv_addr.sin_family=AF_INET;
serv_addr.sin_addr.S_un.S_addr=htonl(inet_addr("192.168.0.96"));
serv_addr.sin_port=htons(400);
if((a=connect(sockfd,(struct sockaddr *)&serv_addr,sizeof(struct sockaddr*)))==0)
printf("the connect is success");
else {
printf("a=%d\n",a);
return -1;
}
但是无法连接上,请问什么原因??