1 #ifndef TB_SESSION_H_ 2 #define TB_SESSION_H_ 3 4 /* 5 * Redistribution and use in source and binary forms, with or 6 * without modification, are permitted provided that the following 7 * conditions are met: 8 * 9 * 1. Redistributions of source code must retain the above 10 * copyright notice, this list of conditions and the 11 * following disclaimer. 12 * 13 * 2. Redistributions in binary form must reproduce the above 14 * copyright notice, this list of conditions and the following 15 * disclaimer in the documentation and/or other materials 16 * provided with the distribution. 17 * 18 * THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ``AS IS'' AND 19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 22 * <COPYRIGHT HOLDER> OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 26 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 29 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 */ 32 33 /* 34 * tarantool v1.6 network session 35 */ 36 37 #include <sys/time.h> 38 39 struct tbbuf { 40 size_t off; 41 size_t top; 42 size_t size; 43 char *buf; 44 }; 45 46 struct tbses { 47 char *host; 48 int port; 49 int connected; 50 struct timeval tmc; 51 int sbuf; 52 int rbuf; 53 int fd; 54 int errno_; 55 struct tbbuf s, r; 56 }; 57 58 enum tbsesopt { 59 TB_HOST, 60 TB_PORT, 61 TB_CONNECTTM, 62 TB_SENDBUF, 63 TB_READBUF 64 }; 65 66 int tb_sesinit(struct tbses*); 67 int tb_sesfree(struct tbses*); 68 int tb_sesset(struct tbses*, enum tbsesopt, ...); 69 int tb_sesconnect(struct tbses*); 70 int tb_sesclose(struct tbses*); 71 int tb_sessync(struct tbses*); 72 ssize_t tb_sessend(struct tbses*, char*, size_t); 73 ssize_t tb_sesrecv(struct tbses*, char*, size_t, int strict); 74 75 #endif 76