中间加几个调试语句
struct hostent *ho=gethostbyname(url);
if (!ho) fprintf(stderr, "WRONG URL\n");
in.sin_addr.s_addr=((unsigned long *)(ho->h_addr_list[0]))[0];
fprintf(stderr, "ip = %s\n", inet_addr(in.sin_addr.s_addr));
in.sin_family=ho->h_addrtype;
in.sin_port=htons(1234);
connect(sock,(struct sockaddr*)&in,sizeof(in));
你看看解释出来的IP地址对不对,然后用telnet ip 1234试试