char *sk_socket_error(Socket s) { return s->error;
void sk_write(Socket s, char *buf, int len) {  if (s->tail && s->tail->buflen < BUFFER_GRANULE) { int copylen = min(len, BUFFER_GRANULE - s->tail->buflen); memcpy(s->tail->buf + s->tail->buflen, buf, copylen); buf += copylen; len -= copylen; s->tail->buflen += copylen; } while (len > 0) { int grainlen = min(len, BUFFER_GRANULE); struct buffer *newbuf; newbuf = smalloc(sizeof(struct buffer)); newbuf->bufpos = 0; newbuf->buflen = grainlen; memcpy(newbuf->buf, buf, grainlen); buf += grainlen; len -= grainlen; if (s->tail) s->tail->next = newbuf; else s->head = s->tail = newbuf; newbuf->next = NULL; s->tail = newbuf; }   if (s->writable) try_send(s);
char *sk_socket_error(Socket s) {    return s->error;}