Changeset cb1f288 in network-game for server


Ignore:
Timestamp:
Nov 23, 2012, 9:13:44 PM (12 years ago)
Author:
dportnoy <dmp1488@…>
Branches:
master
Children:
8efe484
Parents:
6c92572
Message:

Fixed a bug with detecting the client Hello message

File:
1 edited

Legend:

Unmodified
Added
Removed
  • server/server.cpp

    r6c92572 rcb1f288  
    5858      error("binding");
    5959   fromlen = sizeof(struct sockaddr_in);
    60    while (1) {
     60   while (true) {
    6161      n = receiveMessage(&clientMsg, sock, &from);
    6262      if (n < 0)
     
    6464      cout << "msg: " << clientMsg.buffer << endl;
    6565
    66       if (strcmp(clientMsg.buffer, "Hello"))
     66      if (strcmp(clientMsg.buffer, "Hello") == 0)
    6767      {
    6868         strcpy(serverMsg.buffer, "I'm thinking of a number between 1 and 1000. Guess what it is.");
    6969      }else {
    7070         int guess = atoi(clientMsg.buffer);
     71
     72         cout << "guess: " << guess << endl;
    7173
    7274         if (guess < 1 || guess > 1000) {
Note: See TracChangeset for help on using the changeset viewer.