Changeset 4051
- Timestamp:
- Nov 27, 2009, 12:46:27 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
neercs/trunk/src/server.c
r4049 r4051 42 42 static int handle_attach(struct screen_list *screen_list, char *buf); 43 43 44 static int send_to_client(const char *msg, struct screen_list *screen_list)44 static int send_to_client(const char *msg, int size, struct screen_list *screen_list) 45 45 { 46 46 int ret; 47 47 if (!screen_list->socket[SOCK_CLIENT]) 48 48 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, 50 50 screen_list->socket[SOCK_CLIENT]); 51 51 if (!screen_list->socket[SOCK_CLIENT]) 52 52 ret = -1; 53 53 else 54 ret = write(screen_list->socket[SOCK_CLIENT], msg, s trlen(msg));54 ret = write(screen_list->socket[SOCK_CLIENT], msg, size); 55 55 if (ret < 0 && errno != EAGAIN) 56 56 { … … 89 89 bytes = snprintf(buf, sizeof(buf) - 1, "TITLE %s", title); 90 90 buf[bytes] = '\0'; 91 return send_to_client(buf, s creen_list);91 return send_to_client(buf, strlen(buf), screen_list); 92 92 } 93 93 … … 100 100 buf[bytes] = '\0'; 101 101 102 return send_to_client(buf, s creen_list);102 return send_to_client(buf, strlen(buf), screen_list); 103 103 } 104 104 … … 149 149 written = 0; 150 150 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); 154 152 if (ret < 29 && errno != EAGAIN) 155 153 { … … 163 161 /* Block to write the end of the message */ 164 162 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); 168 164 if (n < 0) 169 165 { … … 182 178 caca_get_cursor_y(screen_list->cv)); 183 179 /* 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); 186 181 (void)r; 187 182 #if defined HAVE_CACA_DIRTY_RECTANGLES … … 199 194 if (screen_list->socket[SOCK_CLIENT]) 200 195 { 201 send_to_client("DETACH", screen_list);196 send_to_client("DETACH", 6, screen_list); 202 197 close(screen_list->socket[SOCK_CLIENT]); 203 198 screen_list->socket[SOCK_CLIENT] = 0;
Note: See TracChangeset
for help on using the changeset viewer.