version 1.2.2.1, 2012/02/01 16:18:04
|
version 1.2.2.4, 2012/05/01 22:30:31
|
Line 53 Publish(int sock)
|
Line 53 Publish(int sock)
|
int siz = 0; |
int siz = 0; |
|
|
siz = mqtt_msgPUBLISH(args->msg, AIT_GET_STR(&args->Publish), args->MsgID, args->Dup, |
siz = mqtt_msgPUBLISH(args->msg, AIT_GET_STR(&args->Publish), args->MsgID, args->Dup, |
args->QoS, args->Retain, AIT_GET_PTR2(&args->Value), AIT_LEN(&args->Value)); | args->QoS, args->Retain, AIT_ADDR(&args->Value), AIT_LEN(&args->Value)); |
if (siz == -1) { |
if (siz == -1) { |
printf("Error:: msgPUBLISH #%d - %s\n", mqtt_GetErrno(), mqtt_GetError()); |
printf("Error:: msgPUBLISH #%d - %s\n", mqtt_GetErrno(), mqtt_GetError()); |
return -1; |
return -1; |
Line 89 Publish(int sock)
|
Line 89 Publish(int sock)
|
goto end; |
goto end; |
} |
} |
|
|
siz = mqtt_msgPUBREL(args->msg, args->MsgID); | do { |
if (siz == -1) { | siz = mqtt_msgPUBREL(args->msg, args->MsgID); |
printf("Error:: msgPUBREL #%d - %s\n", mqtt_GetErrno(), mqtt_GetError()); | if (siz == -1) { |
return -1; | printf("Error:: msgPUBREL #%d - %s\n", mqtt_GetErrno(), mqtt_GetError()); |
} | return -1; |
if (SendTo(sock, siz) == -1) | } |
return -1; | if (SendTo(sock, siz) == -1) |
| return -1; |
|
|
if ((siz = RecvFrom(sock)) == -1 || !siz) | if ((siz = RecvFrom(sock)) == -1 || !siz) |
return -1; | return -1; |
|
|
siz = mqtt_readPUBCOMP(args->msg); | siz = mqtt_readPUBCOMP(args->msg); |
if (siz == args->MsgID) | if (siz == args->MsgID) |
return siz; | return siz; |
if (!args->Dup) { | if (!args->Dup) { |
args->Dup++; | args->Dup++; |
return Publish(sock); | continue; |
} | } |
| } while (0); |
|
|
end: |
end: |
printf("Error:: Message not delivered\n"); |
printf("Error:: Message not delivered\n"); |
Line 120 main(int argc, char **argv)
|
Line 122 main(int argc, char **argv)
|
char ch; |
char ch; |
ait_val_t val; |
ait_val_t val; |
u_short port = atoi(MQTT_PORT); |
u_short port = atoi(MQTT_PORT); |
int sock, ret = 0; | int ret = 0; |
|
|
if (!(args = malloc(sizeof(struct tagArgs)))) { |
if (!(args = malloc(sizeof(struct tagArgs)))) { |
printf("Error:: in alloc arguments #%d - %s\n", errno, strerror(errno)); |
printf("Error:: in alloc arguments #%d - %s\n", errno, strerror(errno)); |
Line 227 main(int argc, char **argv)
|
Line 229 main(int argc, char **argv)
|
printf("Connecting to %s:%d ... ", 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 (!(args->cli = mqtt_cli_Open(&args->addr.sa))) { |
args->free(args); |
args->free(args); |
free(args); |
free(args); |
return 2; |
return 2; |
} |
} |
|
|
if (args->isFile && !OpenFile()) { |
if (args->isFile && !OpenFile()) { |
|
mqtt_cli_Close(&args->cli); |
args->free(args); |
args->free(args); |
free(args); |
free(args); |
return 3; |
return 3; |
} |
} |
|
|
switch ((ret = ConnectClient(sock))) { | switch ((ret = ConnectClient(args->cli->sock))) { |
case -1: |
case -1: |
printf(">> FAILED!\n"); |
printf(">> FAILED!\n"); |
break; |
break; |
Line 264 main(int argc, char **argv)
|
Line 267 main(int argc, char **argv)
|
} |
} |
|
|
if (ret == MQTT_RETCODE_ACCEPTED) { |
if (ret == MQTT_RETCODE_ACCEPTED) { |
ret = !(Publish(sock) == args->MsgID); | ret = !(Publish(args->cli->sock) == args->MsgID); |
CloseClient(sock); | } else |
} else { | |
close(sock); | |
ret = 4; |
ret = 4; |
} | |
| mqtt_cli_Close(&args->cli); |
|
|
CloseFile(); |
CloseFile(); |
args->free(args); |
args->free(args); |