- 论坛徽章:
- 0
|
下面是我的程序: \r\n\r\n#define PORTNUM 5000 \r\n\r\n char host[]=\"www.yahoo.com.cn\"; \r\n\r\n SOCKET ServerSock ; // Socket bound to the server \r\n\r\n SOCKADDR_IN destination_sin; // Server socket address \r\n\r\n PHOSTENT phostent = NULL; \r\n\r\n WSADATA WSAData; \r\n\r\nWSAStartup(MAKEWORD(1,1), &WSAData); \r\n\r\n\r\n // Create a TCP/IP socket that is bound to the server. \r\n socket (AF_INET, SOCK_STREAM, 0); \r\n\r\n // Fill out the server socket\'s address information. \r\n destination_sin.sin_family = AF_INET; \r\n\r\n phostent = gethostbyname (host)); \r\n\r\n // Assign the socket IP address. \r\n memcpy ((char FAR *)&(destination_sin.sin_addr),phostent->;h_addr,phostent->;h_length); \r\n\r\n // Convert to network ordering. \r\n destination_sin.sin_port = htons (PORTNUM); \r\n \r\n // Establish a connection to the server socket. \r\n connect (ServerSock,(PSOCKADDR) &destination_sin,sizeof (destination_sin)) \r\n\r\n\r\n WSACleanup(); \r\n\r\n总是连不上,报错说是连接超时,没理由啊。。。。哪位大虾帮忙看下啦!! \r\n\r\n small_snap \r\n a million thanks |
|