ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/socket/lowlevel.C
(Generate patch)

Comparing deliantra/server/socket/lowlevel.C (file contents):
Revision 1.12 by root, Thu Dec 14 00:01:37 2006 UTC vs.
Revision 1.13 by root, Thu Dec 14 01:12:35 2006 UTC

118SockList::printf (const char *format, ...) 118SockList::printf (const char *format, ...)
119{ 119{
120 va_list ap; 120 va_list ap;
121 va_start (ap, format); 121 va_start (ap, format);
122 122
123 len += vsprintf ((char *)buf + len, format, ap); 123 len += vsnprintf ((char *)buf + len, MAXSOCKBUF, format, ap);
124 124
125 va_end (ap); 125 va_end (ap);
126} 126}
127 127
128/****************************************************************************** 128/******************************************************************************
360 cst_lst.obytes += amt; 360 cst_lst.obytes += amt;
361#endif 361#endif
362 } 362 }
363} 363}
364 364
365
366/** 365/**
367 * Takes a string of data, and writes it out to the socket. A very handy 366 * Takes a string of data, and writes it out to the socket. A very handy
368 * shortcut function. 367 * shortcut function.
369 */ 368 */
370void
371cs_write_string (NewSocket *ns, const char *buf, int len)
372{
373 SockList sl;
374 369
375 sl.len = len; 370void
376 sl.buf = (unsigned char *) buf; 371NewSocket::send_packet (SockList &sl)
372{
377 Send_With_Handling (ns, &sl); 373 Send_With_Handling (this, &sl);
378} 374}
379 375
376void
377NewSocket::send_packet (const char *buf, int len)
378{
379 SockList sl (MAXSOCKBUF);
380
381 sl << data (buf, len);
382 send_packet (sl);
383 sl.free ();
384}
385
386void
387NewSocket::send_packet (const char *buf)
388{
389 send_packet (buf, strlen (buf));
390}
380 391
381/** 392/**
382 * Calls Write_To_Socket to send data to the client. 393 * Calls Write_To_Socket to send data to the client.
383 * 394 *
384 * The only difference in this function is that we take a SockList 395 * The only difference in this function is that we take a SockList
404 sbuf[1] = ((uint32) (msg->len)) & 0xFF; 415 sbuf[1] = ((uint32) (msg->len)) & 0xFF;
405 if (ns->status != Ns_Old) 416 if (ns->status != Ns_Old)
406 Write_To_Socket (ns, (char *) sbuf, 2); 417 Write_To_Socket (ns, (char *) sbuf, 2);
407 Write_To_Socket (ns, (char *) msg->buf, msg->len); 418 Write_To_Socket (ns, (char *) msg->buf, msg->len);
408} 419}
409
410/**
411 * Takes a string of data, and writes it out to the socket. A very handy
412 * shortcut function.
413 */
414void
415Write_String_To_Socket (NewSocket *ns, char *buf, int len)
416{
417 SockList sl;
418
419 sl.len = len;
420 sl.buf = (unsigned char *) buf;
421 Send_With_Handling (ns, &sl);
422}
423
424 420
425/****************************************************************************** 421/******************************************************************************
426 * 422 *
427 * statistics logging functions. 423 * statistics logging functions.
428 * 424 *

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines