nanohttp-socket.h

Go to the documentation of this file.
00001 /******************************************************************
00002  *  $Id: nanohttp-socket.h,v 1.38 2006/12/11 08:13:19 m0gg Exp $
00003  *
00004  * CSOAP Project:  A http client/server library in C
00005  * Copyright (C) 2003  Ferhat Ayaz
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Library General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Library General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Library General Public
00018  * License along with this library; if not, write to the
00019  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00020  * Boston, MA  02111-1307, USA.
00021  * 
00022  * Email: ayaz@jprogrammer.net
00023  ******************************************************************/
00024 #ifndef __nanohttp_socket_h
00025 #define __nanohttp_socket_h
00026 
00031 
00037 #define HSOCKET_ERROR                   1000
00038 #define HSOCKET_ERROR_CREATE            (HSOCKET_ERROR + 1)
00039 #define HSOCKET_ERROR_GET_HOSTNAME      (HSOCKET_ERROR + 2)
00040 #define HSOCKET_ERROR_CONNECT           (HSOCKET_ERROR + 3)
00041 #define HSOCKET_ERROR_SEND              (HSOCKET_ERROR + 4)
00042 #define HSOCKET_ERROR_RECEIVE           (HSOCKET_ERROR + 5)
00043 #define HSOCKET_ERROR_BIND              (HSOCKET_ERROR + 6)
00044 #define HSOCKET_ERROR_LISTEN            (HSOCKET_ERROR + 7)
00045 #define HSOCKET_ERROR_ACCEPT            (HSOCKET_ERROR + 8)
00046 #define HSOCKET_ERROR_NOT_INITIALIZED   (HSOCKET_ERROR + 9)
00047 #define HSOCKET_ERROR_IOCTL             (HSOCKET_ERROR + 10)
00048 
00056 #define HSOCKET_ERROR_SSLCLOSE          (HSOCKET_ERROR + 11)
00057 #define HSOCKET_ERROR_SSLCTX            (HSOCKET_ERROR + 11)
00058 
00059 /*}*/
00060 
00066 struct hsocket_t
00067 {
00068 #ifdef WIN32
00069   SOCKET sock;
00070 #else
00071   int sock;
00072 #endif
00073   struct sockaddr_in addr;
00074   size_t bytes_transmitted;
00075   size_t bytes_received;
00076   void *ssl;
00077 };
00078 
00079 #ifdef __cplusplus
00080 extern "C"
00081 {
00082 #endif
00083 
00092 extern herror_t hsocket_module_init(int argc, char **argv);
00093 
00094 
00103 extern void hsocket_module_destroy(void);
00104 
00117 extern herror_t hsocket_init(struct hsocket_t * sock);
00118 
00126 extern void hsocket_free(struct hsocket_t * sock);
00127 
00144 extern herror_t hsocket_open(struct hsocket_t *sock, const char *host, int port, int ssl);
00145 
00153 extern void hsocket_close(struct hsocket_t *sock);
00154 
00170 extern herror_t hsocket_bind(struct hsocket_t *sock, unsigned short port);
00171 
00184 extern herror_t hsocket_listen(struct hsocket_t *sock);
00185 
00198 extern herror_t hsocket_accept(struct hsocket_t *sock, struct hsocket_t *dest);
00199 
00212 extern herror_t hsocket_send(struct hsocket_t *sock, const unsigned char *bytes, int size);
00213 
00226 extern herror_t hsocket_send_string(struct hsocket_t *sock, const char *str);
00227 
00228 extern int hsocket_select_recv(int sock, char *buf, size_t len);
00229 
00245 extern herror_t hsocket_recv(struct hsocket_t * sock, unsigned char *buffer, int size, int force, int *len);
00246 
00256 extern int hsocket_get_timeout(void);
00257 
00267 extern void hsocket_set_timeout(int secs);
00268 
00269 #ifdef __cplusplus
00270 }
00271 #endif
00272 
00273 #endif

Generated on Thu Jan 25 23:36:03 2007 for csoap by  doxygen 1.4.6