From 5135deef30728b9da304b4fd596d1295825b371c Mon Sep 17 00:00:00 2001 From: Alexander Vdolainen Date: Fri, 8 Jul 2016 01:51:27 +0300 Subject: [PATCH] sxt: socket wrapper header with API added; --- include/sxt/socket.h | 57 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 include/sxt/socket.h diff --git a/include/sxt/socket.h b/include/sxt/socket.h new file mode 100644 index 0000000..fb9e633 --- /dev/null +++ b/include/sxt/socket.h @@ -0,0 +1,57 @@ +/* + * Secure eXtended Message Passing framework + * Secure eXtended Transport layer implementation (libsxt). + * + * socket wrapper + * + * (c) Alexander Vdolainen 2016 + * + * libsxmp is free software: you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * libsxmp is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see ."; + * + */ + +#ifndef __SXT_SOCKET_H__ +#define __SXT_SOCKET_H__ + +enum { + SXTSOCKET_NIL = 0, + SXTSOCKET_ACTIVE, + SXTSOCKET_DEAD, +}; + +#define SXTSCK_RDR (1 << 1) +#define SXTSCK_WRR (1 << 2) +#define SXTSCT_TMO (1 << 3) + +typedef struct __sxtsocket_type { + uint8_t state; + int fd; +} sxtsocket_t; + +/* API */ +sxtsocket_t *sxtsocket_new(); + +int sxtsocket_close(sxtsocket_t *); + +int sxtsocket_setnb(sxtsocket_t *); + +size_t sxtsocket_read(sxtsocket_t *, void *, size_t); + +size_t sxtsocket_write(sxtsocket_t *, void *, size_t); + +int sxtsocket_poll(sxtsocket_t **, int, sxtsocket_t **, int, void *); + +void sxtsocket_free(sxtsocket_t *); + +#endif /* __SXT_SOCKET_H__ */