发布网友 发布时间:2022-05-18 18:36
共2个回答
热心网友 时间:2023-07-06 16:58
#include <windows.h> #include <stdio.h> #include <winsock.h> #pragma comment(lib,"ws2_32") #define PORT 1129 #define ADDRESS "127.0.0.1/socket.asp" int main() { WSADATA wsaData; WORD sockVersion = MAKEWORD(2,2); if(WSAStartup(sockVersion,&wsaData)!=0) return 0; SOCKET sClient = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP); if(sClient==INVALID_SOCKET) { printf("socket error\n"); return 0; } sockaddr_in remote; remote.sin_family = AF_INET; remote.sin_port = htons(1129); remote.sin_addr.s_addr = inet_addr(ADDRESS); if(connect(sClient,(SOCKADDR *)&remote,sizeof(SOCKADDR))==SOCKET_ERROR) { printf("connect error\n"); closesocket(sClient); return 0; } while(true) { char SendData[255]; int i,ch; for( i = 0; (i < 254) && ((ch = getchar()) != EOF) && (ch!='\n'); i++) SendData[i] = (char)ch; SendData[i] = '\n'; SendData[i+1] = '\0'; send(sClient,SendData,i+2,0); } closesocket(sClient); WSACleanup(); return 0; } //帮你修改了下...可编译过...VC6.0热心网友 时间:2023-07-06 16:58
明后天去济南的车票,上午十点或下午两点的有没有