src/siri/net/pkg.c
/*
 * Returns 0 if successful or -1 when an error has occurred.
 * (signal is raised in case of an error)
 *
 * Note: pkg will be freed after calling this function.
 */
Returns 0 if successful or -1 when an error has occurred.
(signal is raised in case of an error)

pkg will be freed after calling this function.
Returns 0 if successful or - 1 when an error has occurred . ( signal is raised in case of an error ) pkg will be freed after calling this function .
int sirinet_pkg_send(uv_stream_t * client, sirinet_pkg_t * pkg)
{
    uv_write_t * req = (uv_write_t *) malloc(sizeof(uv_write_t));
    if (req == NULL)
    {
        ERR_ALLOC
        free(pkg);
        return -1;
    }
    pkg_send_t * data = (pkg_send_t *) malloc(sizeof(pkg_send_t));
    if (data == NULL)
    {
        ERR_ALLOC
        free(pkg);
        free(req);
        return -1;
    }
    sirinet_socket_incref(client);
    data->client = client;
    data->pkg = pkg;
    req->data = data;
    pkg->checkbit = pkg->tp ^ 255;
    uv_buf_t wrbuf = uv_buf_init(
            (char *) pkg,
            sizeof(sirinet_pkg_t) + pkg->len);
    uv_write(req, client, &wrbuf, 1, PKG_write_cb);
    return 0;
}
int sirinet_pkg_send ( uv_stream_t * client , sirinet_pkg_t * pkg ) { uv_write_t * req = ( uv_write_t * ) malloc ( sizeof ( uv_write_t ) ) ; if ( req == NULL ) { ERR_ALLOC free ( pkg ) ; return -1 ; } pkg_send_t * data = ( pkg_send_t * ) malloc ( sizeof ( pkg_send_t ) ) ; if ( data == NULL ) { ERR_ALLOC free ( pkg ) ; free ( req ) ; return -1 ; } sirinet_socket_incref ( client ) ; data -> client = client ; data -> pkg = pkg ; req -> data = data ; pkg -> checkbit = pkg -> tp ^ 255 ; uv_buf_t wrbuf = uv_buf_init ( ( char * ) pkg , sizeof ( sirinet_pkg_t ) + pkg -> len ) ; uv_write ( req , client , & wrbuf , 1 , PKG_write_cb ) ; return 0 ; }
Returns 0 if successful or -1 when an error has occurred.
Returns 0 if successful or - 1 when an error has occurred .
/* increment client reference counter */ /* set the correct check bit */