Changeset 8efe484 in network-game for client/Client/main.cpp
- Timestamp:
- Nov 23, 2012, 9:33:32 PM (12 years ago)
- Branches:
- master
- Children:
- e08572c
- Parents:
- cb1f288
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
client/Client/main.cpp
rcb1f288 r8efe484 64 64 server.sin_port = htons(atoi(argv[2])); 65 65 66 strcpy(msgTo.buffer, "Hello"); 67 n=sendMessage(&msgTo, sock, &server); 68 if (n < 0) 69 error("sendMessage"); 70 71 n = receiveMessage(&msgFrom, sock, &from); 72 if (n < 0) 73 error("receiveMessage"); 74 75 cout << msgFrom.buffer << endl; 76 66 77 while(true) { 67 cout << "Please enter the message: ";78 cout << "Please enter a message (or q to quit): "; 68 79 cin.getline(msgTo.buffer, 256); 69 80 70 if (strcmp(msgTo.buffer, "q uit") == 0) {81 if (strcmp(msgTo.buffer, "q") == 0) { 71 82 break; 72 83 } 73 84 74 socklen_t socklen = sizeof(server);75 85 n=sendMessage(&msgTo, sock, &server); 76 86 if (n < 0) … … 84 94 } 85 95 86 cout << "Thank you for playing!" << endl;87 88 96 closesocket(sock); 89 97 90 98 WSACleanup(); 99 100 cout << "Thank you for playing!" << endl; 101 getchar(); 91 102 92 103 return 0;
Note:
See TracChangeset
for help on using the changeset viewer.