version 1.1.2.1, 2012/01/30 13:39:22
|
version 1.1.2.2, 2012/01/30 22:58:24
|
Line 40 Ping(int sock)
|
Line 40 Ping(int sock)
|
int siz = 0; |
int siz = 0; |
struct timeval before, after; |
struct timeval before, after; |
ait_val_t val; |
ait_val_t val; |
|
struct mqtthdr *hdr; |
|
|
gettimeofday(&before, NULL); |
gettimeofday(&before, NULL); |
|
|
Line 51 Ping(int sock)
|
Line 52 Ping(int sock)
|
if (SendTo(sock, siz) == -1) |
if (SendTo(sock, siz) == -1) |
return -1; |
return -1; |
|
|
if ((siz = RecvFrom(sock)) == -1 || !siz) | do { |
return -1; | if ((siz = RecvFrom(sock)) == -1 || !siz) |
siz = mqtt_readPINGRESP(args->msg); | return -1; |
if (siz == -1) { | else |
printf("Error:: readPINGRESP #%d - %s\n", mqtt_GetErrno(), mqtt_GetError()); | hdr = (struct mqtthdr*) args->msg->msg_base; |
return -1; | if (hdr->mqtt_msg.type == MQTT_TYPE_PINGREQ) { |
} | siz = mqtt_msgPINGRESP(args->msg); |
| if (siz == -1) { |
| printf("Error:: msgPINGRESP #%d - %s\n", mqtt_GetErrno(), mqtt_GetError()); |
| return -1; |
| } |
| if (SendTo(sock, siz) == -1) |
| return -1; |
| } else { |
| siz = mqtt_readPINGRESP(args->msg); |
| if (siz == -1) { |
| printf("Error:: readPINGRESP #%d - %s\n", mqtt_GetErrno(), mqtt_GetError()); |
| return -1; |
| } else |
| break; |
| } |
| } while (42); |
|
|
gettimeofday(&after, NULL); |
gettimeofday(&after, NULL); |
|
|
printf("Ping MQTT broker %s ... %f sec.\n", io_n2addr(&args->addr, &val), | printf(" + Ping MQTT broker %s ... %f sec.\n", io_n2addr(&args->addr, &val), |
((after.tv_sec - before.tv_sec) + (after.tv_usec - before.tv_usec) / 1.e6)); |
((after.tv_sec - before.tv_sec) + (after.tv_usec - before.tv_usec) / 1.e6)); |
AIT_FREE_VAL(&val); |
AIT_FREE_VAL(&val); |
|
|
Line 141 main(int argc, char **argv)
|
Line 157 main(int argc, char **argv)
|
Usage(); |
Usage(); |
return 1; |
return 1; |
} |
} |
ioVERBOSE(1) printf("Connecting to %s:%d ...\n", io_n2addr(&args->addr, &val), io_n2port(&args->addr)); | printf("Connecting to %s:%d ... ", io_n2addr(&args->addr, &val), io_n2port(&args->addr)); |
AIT_FREE_VAL(&val); |
AIT_FREE_VAL(&val); |
|
|
if ((sock = InitClient()) == -1) { |
if ((sock = InitClient()) == -1) { |