Changeset 6c92572 in network-game for client/Client/main.cpp
- Timestamp:
- Nov 23, 2012, 9:05:22 PM (12 years ago)
- Branches:
- master
- Children:
- cb1f288
- Parents:
- e084950
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
client/Client/main.cpp
re084950 r6c92572 63 63 memcpy((char *)&server.sin_addr, (char *)hp->h_addr, hp->h_length); 64 64 server.sin_port = htons(atoi(argv[2])); 65 cout << "Please enter the message: ";66 cin.getline(msgTo.buffer, 256);67 socklen_t socklen = sizeof(server);68 65 69 n=sendMessage(&msgTo, sock, &server); 70 if (n < 0) 71 error("sendMessage"); 66 while(true) { 67 cout << "Please enter the message: "; 68 cin.getline(msgTo.buffer, 256); 69 70 if (strcmp(msgTo.buffer, "quit") == 0) { 71 break; 72 } 72 73 73 n = receiveMessage(&msgFrom, sock, &from); 74 if (n < 0) 75 error("receiveMessage"); 74 socklen_t socklen = sizeof(server); 75 n=sendMessage(&msgTo, sock, &server); 76 if (n < 0) 77 error("sendMessage"); 78 79 n = receiveMessage(&msgFrom, sock, &from); 80 if (n < 0) 81 error("receiveMessage"); 76 82 77 cout << "Got an ack: " << endl; 78 cout << msgFrom.buffer << endl; 83 cout << msgFrom.buffer << endl; 84 } 85 86 cout << "Thank you for playing!" << endl; 79 87 80 88 closesocket(sock);
Note:
See TracChangeset
for help on using the changeset viewer.