mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-11-16 02:08:21 +01:00
f960b3872a
Documented headers.lua Update copyright date everywhere Remove RCSID from files Move version back to 2.1 rather than 2.1.1 Fixed url package to support ipv6 hosts Changed "domain" to "family" in tcp and udp structures Implemented getfamily methods
31 lines
1.1 KiB
C
31 lines
1.1 KiB
C
/*=========================================================================*\
|
|
* Input/Output abstraction
|
|
* LuaSocket toolkit
|
|
\*=========================================================================*/
|
|
#include "io.h"
|
|
|
|
/*=========================================================================*\
|
|
* Exported functions
|
|
\*=========================================================================*/
|
|
/*-------------------------------------------------------------------------*\
|
|
* Initializes C structure
|
|
\*-------------------------------------------------------------------------*/
|
|
void io_init(p_io io, p_send send, p_recv recv, p_error error, void *ctx) {
|
|
io->send = send;
|
|
io->recv = recv;
|
|
io->error = error;
|
|
io->ctx = ctx;
|
|
}
|
|
|
|
/*-------------------------------------------------------------------------*\
|
|
* I/O error strings
|
|
\*-------------------------------------------------------------------------*/
|
|
const char *io_strerror(int err) {
|
|
switch (err) {
|
|
case IO_DONE: return NULL;
|
|
case IO_CLOSED: return "closed";
|
|
case IO_TIMEOUT: return "timeout";
|
|
default: return "unknown error";
|
|
}
|
|
}
|