source: trunk/third-party/shttpd/io_socket.c @ 5822

Last change on this file since 5822 was 5822, checked in by charles, 14 years ago

Add shttpd (http://shttpd.sourceforge.net/) to the list of third-party tools

File size: 909 bytes
Line 
1/*
2 * Copyright (c) 2004-2005 Sergey Lyubka <valenok@gmail.com>
3 * All rights reserved
4 *
5 * "THE BEER-WARE LICENSE" (Revision 42):
6 * Sergey Lyubka wrote this file.  As long as you retain this notice you
7 * can do whatever you want with this stuff. If we meet some day, and you think
8 * this stuff is worth it, you can buy me a beer in return.
9 */
10
11#include "defs.h"
12
13static int
14read_socket(struct stream *stream, void *buf, size_t len)
15{
16        assert(stream->chan.sock != -1);
17        return (recv(stream->chan.sock, buf, len, 0));
18}
19
20static int
21write_socket(struct stream *stream, const void *buf, size_t len)
22{
23        assert(stream->chan.sock != -1);
24        return (send(stream->chan.sock, buf, len, 0));
25}
26
27static void
28close_socket(struct stream *stream)
29{
30        assert(stream->chan.sock != -1);
31        (void) closesocket(stream->chan.sock);
32}
33
34const struct io_class   io_socket =  {
35        "socket",
36        read_socket,
37        write_socket,
38        close_socket
39};
Note: See TracBrowser for help on using the repository browser.