You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
libsxmp/include/sxt/socket.h

61 lines
1.6 KiB
C

/*
* Secure eXtended Message Passing framework
* Secure eXtended Transport layer implementation (libsxt).
*
* socket wrapper
*
* (c) Alexander Vdolainen 2016 <avdolainen@zoho.com>
*
* 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 2.1 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 <http://www.gnu.org/licenses/>.";
*
*/
#ifndef __SXT_SOCKET_H__
#define __SXT_SOCKET_H__
enum {
SXTSOCKET_NIL = 0,
SXTSOCKET_ACTIVE,
SXTSOCKET_DEAD,
SXTSOCKET_CLOSED,
};
#define SXTSCK_RDR (1 << 1)
#define SXTSCK_WRR (1 << 2)
#define SXTSCT_TMO (1 << 3)
#define SXTSCT_ERR (1 << 4)
typedef struct __sxtsocket_type {
uint8_t state;
int fd;
} sxtsocket_t;
/* API */
sxtsocket_t *sxtsocket_new(void);
int sxtsocket_close(sxtsocket_t *);
int sxtsocket_setnb(sxtsocket_t *);
ssize_t sxtsocket_read(sxtsocket_t *, void *, size_t);
ssize_t sxtsocket_write(sxtsocket_t *, void *, size_t);
int sxtsocket_poll(sxtsocket_t **, int, sxtsocket_t **, int, int, int **,
int **);
void sxtsocket_free(sxtsocket_t *);
#endif /* __SXT_SOCKET_H__ */