Annotation of mqtt/src/client.c, revision 1.1.2.5

1.1.2.1   misho       1: #include "global.h"
                      2: #include "mqtt.h"
                      3: 
                      4: 
                      5: int
                      6: InitClient(void)
                      7: {
                      8:        int sock;
                      9: 
                     10:        sock = socket(args->addr.sa.sa_family, SOCK_STREAM, IPPROTO_TCP);
                     11:        if (sock == -1) {
                     12:                printf("Error:: socket() #%d - %s\n", errno, strerror(errno));
                     13:                return -1;
                     14:        }
                     15:        if (connect(sock, &args->addr.sa, args->addr.sa.sa_len) == -1) {
                     16:                printf("Error:: connect() #%d - %s\n", errno, strerror(errno));
                     17:                return -1;
                     18:        }
                     19: 
                     20:        return sock;
                     21: }
1.1.2.2   misho      22: 
                     23: int
1.1.2.4   misho      24: try2Connect(int sock)
1.1.2.2   misho      25: {
1.1.2.4   misho      26:        int siz = 0;
                     27: 
1.1.2.5 ! misho      28:        siz = mqtt_msgCONNECT(args->msg, AIT_GET_STR(&args->ConnID), args->ka, 
        !            29:                        AIT_GET_STR(&args->User), AIT_GET_STR(&args->Pass), 
        !            30:                        args->Will.Topic.val.string, args->Will.Msg.val.string, 
        !            31:                        !args->notClear, args->QoS, args->Retain);
1.1.2.4   misho      32:        if (siz == -1) {
                     33:                printf("Error:: msgCONNECT #%d - %s\n", mqtt_GetErrno(), mqtt_GetError());
                     34:                return -1;
                     35:        }
                     36: 
                     37:        siz = send(sock, args->msg->msg_base, siz, 0);
                     38:        if (siz == -1) {
                     39:                printf("Error:: send() #%d - %s\n", errno, strerror(errno));
                     40:                return -1;
                     41:        } else
                     42:                VERB(3) printf("Sended CONNECT %d bytes\n", siz);
                     43: 
1.1.2.5 ! misho      44:        register int i;
        !            45:        for (i = 0; i < siz; i++)
        !            46:                printf("%02x ", ((u_char*)args->msg->msg_base)[i]);
        !            47:        printf("\n");
1.1.2.4   misho      48:        return siz;
1.1.2.2   misho      49: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>