--- deliantra/server/socket/lowlevel.C 2006/12/14 05:09:32 1.18 +++ deliantra/server/socket/lowlevel.C 2006/12/14 20:39:54 1.19 @@ -372,15 +372,41 @@ } } +void +client_socket::socket_cb (iow &w, int got) +{ + //printf ("iow got %x\n", got); + w.stop (); +} + /** * Takes a string of data, and writes it out to the socket. A very handy * shortcut function. */ - void client_socket::send_packet (packet &sl) { - Send_With_Handling (this, &sl); + if (status == Ns_Dead) + return; + + if (sl.length () >= MAXSOCKBUF) + { + LOG (llevError, "Trying to send a buffer beyond properly size, len =%d\n", sl.length ()); + /* Almost certainly we've overflowed a buffer, so quit now to make + * it easier to debug. + */ + abort (); + } + + if (!sl.length ()) + return; + + assert (sl.hdrlen == 2); + + sl.buf_ [0] = sl.length () >> 8; + sl.buf_ [1] = sl.length () ; + + send (sl.buf_, sl.length () + sl.hdrlen); } void @@ -398,37 +424,6 @@ send_packet (buf, strlen (buf)); } -/** - * Calls Write_To_Socket to send data to the client. - * - * The only difference in this function is that we take a packet - *, and we prepend the length information. - */ -void -Send_With_Handling (client_socket *ns, packet *msg) -{ - unsigned char sbuf[4]; - - if (ns->status == Ns_Dead || !msg) - return; - - if (msg->length () >= MAXSOCKBUF) - { - LOG (llevError, "Trying to send a buffer beyond properly size, len =%d\n", msg->length ()); - /* Almost certainly we've overflowed a buffer, so quite now to make - * it easier to debug. - */ - abort (); - } - - sbuf[0] = ((uint32) (msg->length ()) >> 8); - sbuf[1] = ((uint32) (msg->length ()) ); - - //TODO: single write, or writev - ns->send (sbuf, 2); - ns->send (msg->buf, msg->length ()); -} - /****************************************************************************** * * statistics logging functions.