汗,那是你输入的结构,里面IP和PORT是你指定的,你现在倒问怎么得到它们?[?][?][?]<br><br> //<br> // Create the socket, and attempt to connect to the server<br> //<br> sClient = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);<br> if (sClient == INVALID_SOCKET)<br> {<br> printf("socket() failed: %d/n", WSAGetLastError());<br> return 1;<br> }<br> server.sin_family = AF_INET;<br> server.sin_port = htons(iPort);<br> server.sin_addr.s_addr = inet_addr(szServer);<br> //<br> // If the supplied server address wasn't in the form<br> // "aaa.bbb.ccc.ddd" it's a hostname, so try to resolve it<br> //<br> if (server.sin_addr.s_addr == INADDR_NONE)<br> {<br> host = gethostbyname(szServer);<br> if (host == NULL)<br> {<br> printf("Unable to resolve server: %s/n", szServer);<br> return 1;<br> }<br> CopyMemory(&server.sin_addr, host->h_addr_list[0],<br> host->h_length);<br> }<br> if (connect(sClient, (struct sockaddr *)&server, <br> sizeof(server)) == SOCKET_ERROR)<br> {<br> printf("connect() failed: %d/n", WSAGetLastError());<br> return 1;<br> }