Changeset 4051 for neercs


Ignore:
Timestamp:
Nov 27, 2009, 12:46:27 PM (10 years ago)
Author:
Jean-Yves Lamoureux
Message:
  • Replaced direct write()'s on socket by send_to_client(). Should not break anything.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • neercs/trunk/src/server.c

    r4049 r4051  
    4242static int handle_attach(struct screen_list *screen_list, char *buf);
    4343
    44 static int send_to_client(const char *msg, struct screen_list *screen_list)
     44static int send_to_client(const char *msg, int size, struct screen_list *screen_list)
    4545{
    4646    int ret;
    4747    if (!screen_list->socket[SOCK_CLIENT])
    4848        connect_socket(screen_list, SOCK_CLIENT);
    49     debug("Sending message (%.8s,%d) to client on socket %d", msg, strlen(msg),
     49    debug("Sending message (%s,%d) to client on socket %d", msg, size,
    5050          screen_list->socket[SOCK_CLIENT]);
    5151    if (!screen_list->socket[SOCK_CLIENT])
    5252        ret = -1;
    5353    else
    54         ret = write(screen_list->socket[SOCK_CLIENT], msg, strlen(msg));
     54        ret = write(screen_list->socket[SOCK_CLIENT], msg, size);
    5555    if (ret < 0 && errno != EAGAIN)
    5656    {
     
    8989    bytes = snprintf(buf, sizeof(buf) - 1, "TITLE %s", title);
    9090    buf[bytes] = '\0';
    91     return send_to_client(buf, screen_list);
     91    return send_to_client(buf, strlen(buf), screen_list);
    9292}
    9393
     
    100100    buf[bytes] = '\0';
    101101
    102     return send_to_client(buf, screen_list);
     102    return send_to_client(buf, strlen(buf), screen_list);
    103103}
    104104
     
    149149            written = 0;
    150150            sprintf(buf2, "UPDATE %10d %10d", x, y);
    151             ret =
    152                 write(screen_list->socket[SOCK_CLIENT], buf2,
    153                       strlen(buf2) + 1);
     151            ret = send_to_client(buf2, strlen(buf2)+1, screen_list);
    154152            if (ret < 29 && errno != EAGAIN)
    155153            {
     
    163161                /* Block to write the end of the message */
    164162                fcntl(screen_list->socket[SOCK_CLIENT], F_SETFL, 0);
    165                 n = write(screen_list->socket[SOCK_CLIENT],
    166                           (char *)buf + written,
    167                           towrite > bufsize ? bufsize : towrite);
     163                n = send_to_client((char*) buf+written, towrite > bufsize ? bufsize : towrite, screen_list);
    168164                if (n < 0)
    169165                {
     
    182178                caca_get_cursor_y(screen_list->cv));
    183179        /* FIXME check value of r */
    184         int r =
    185             write(screen_list->socket[SOCK_CLIENT], buf2, strlen(buf2) + 1);
     180            int r = send_to_client(buf2, strlen(buf2) + 1,screen_list);
    186181        (void)r;
    187182#if defined HAVE_CACA_DIRTY_RECTANGLES
     
    199194    if (screen_list->socket[SOCK_CLIENT])
    200195    {
    201         send_to_client("DETACH", screen_list);
     196        send_to_client("DETACH", 6, screen_list);
    202197        close(screen_list->socket[SOCK_CLIENT]);
    203198        screen_list->socket[SOCK_CLIENT] = 0;
Note: See TracChangeset for help on using the changeset viewer.