/* Low-level data write callback for the simplified SSL I/O API.  */
static int sock_write(void *ctx, const unsigned char *buf, size_t len)
/* Low-level data write callback for the simplified SSL I/O API.  */
static int sock_write(void *ctx, const unsigned char *buf, size_t len)
{
	for (;;) {
		ssize_t wlen;
		wlen = write(*(int *)ctx, buf, len);
		if (wlen <= 0) {
			if (wlen < 0 && errno == EINTR) {
				continue;
			}
			return -1;
		}
		return (int)wlen;
	}
}