gwenhywfar  4.11.0beta
inetsocket.h
Go to the documentation of this file.
1 /***************************************************************************
2  $RCSfile$
3  -------------------
4  cvs : $Id$
5  begin : Tue Oct 02 2002
6  copyright : (C) 2002 by Martin Preuss
7  email : martin@libchipcard.de
8 
9  ***************************************************************************
10  * *
11  * This library is free software; you can redistribute it and/or *
12  * modify it under the terms of the GNU Lesser General Public *
13  * License as published by the Free Software Foundation; either *
14  * version 2.1 of the License, or (at your option) any later version. *
15  * *
16  * This library is distributed in the hope that it will be useful, *
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
19  * Lesser General Public License for more details. *
20  * *
21  * You should have received a copy of the GNU Lesser General Public *
22  * License along with this library; if not, write to the Free Software *
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
24  * MA 02111-1307 USA *
25  * *
26  ***************************************************************************/
27 
33 #ifndef GWEN_SOCKET_H
34 #define GWEN_SOCKET_H
35 
37 #include <gwenhywfar/error.h>
38 #include <gwenhywfar/inetaddr.h>
39 #include <gwenhywfar/list1.h>
40 #include <gwenhywfar/list2.h>
41 
42 
43 typedef struct GWEN_SOCKET GWEN_SOCKET;
44 typedef struct GWEN_SOCKETSETSTRUCT GWEN_SOCKETSET;
45 
48 
49 
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53 
54 
65 #define GWEN_SOCKET_ERROR_TYPE "Socket"
66 #define GWEN_SOCKET_ERROR_BAD_SOCKETTYPE (-1)
67 #define GWEN_SOCKET_ERROR_NOT_OPEN (-2)
68 #define GWEN_SOCKET_ERROR_TIMEOUT (-3)
69 #define GWEN_SOCKET_ERROR_IN_PROGRESS (-4)
70 #define GWEN_SOCKET_ERROR_STARTUP (-5)
71 #define GWEN_SOCKET_ERROR_INTERRUPTED (-6)
72 #define GWEN_SOCKET_ERROR_UNSUPPORTED (-7)
73 #define GWEN_SOCKET_ERROR_ABORTED (-8)
74 #define GWEN_SOCKET_ERROR_BROKEN_PIPE (-9)
75 
81 typedef enum {
88 
89 
90 
122  const GWEN_SOCKET *sp);
125  const GWEN_SOCKET *sp);
127  const GWEN_SOCKET *sp);
129 
131 /*end of group socketset */
146 
150 GWENHYWFAR_API GWEN_SOCKET *GWEN_Socket_new(GWEN_SOCKETTYPE socketType);
151 
152 GWENHYWFAR_API GWEN_SOCKET *GWEN_Socket_fromFile(int fd);
153 
157 GWENHYWFAR_API void GWEN_Socket_free(GWEN_SOCKET *sp);
158 
163 GWENHYWFAR_API int GWEN_Socket_Open(GWEN_SOCKET *sp);
164 
168 GWENHYWFAR_API int GWEN_Socket_Close(GWEN_SOCKET *sp);
178 int GWEN_Socket_Connect(GWEN_SOCKET *sp, const GWEN_INETADDRESS *addr);
179 
181 int GWEN_Socket_Bind(GWEN_SOCKET *sp, const GWEN_INETADDRESS *addr);
182 
183 GWENHYWFAR_API int GWEN_Socket_Listen(GWEN_SOCKET *sp, int backlog);
184 
200 int GWEN_Socket_Accept(GWEN_SOCKET *sp,
201  GWEN_INETADDRESS **addr,
202  GWEN_SOCKET **newsock);
203 
213 
219 
220 
229  int GWEN_Socket_GetPeerAddr(GWEN_SOCKET *sp,
230  GWEN_INETADDRESS **addr);
231 
242  GWEN_SOCKETSET *ws,
243  GWEN_SOCKETSET *xs,
244  int timeout);
245 
252  int GWEN_Socket_WaitForRead(GWEN_SOCKET *sp, int timeout);
253 
260  int GWEN_Socket_WaitForWrite(GWEN_SOCKET *sp, int timeout);
270 
281 GWENHYWFAR_API int GWEN_Socket_Read(GWEN_SOCKET *sp,
282  char *buffer,
283  int *bsize);
284 
293 GWENHYWFAR_API int GWEN_Socket_Write(GWEN_SOCKET *sp,
294  const char *buffer,
295  int *bsize);
296 
310  int GWEN_Socket_ReadFrom(GWEN_SOCKET *sp,
311  GWEN_INETADDRESS **addr,
312  char *buffer,
313  int *bsize);
324  int GWEN_Socket_WriteTo(GWEN_SOCKET *sp,
325  const GWEN_INETADDRESS *addr,
326  const char *buffer,
327  int *bsize);
341 GWENHYWFAR_API int GWEN_Socket_SetBlocking(GWEN_SOCKET *sp, int fl);
350 GWENHYWFAR_API int GWEN_Socket_SetBroadcast(GWEN_SOCKET *sp, int fl);
351 
360 GWENHYWFAR_API int GWEN_Socket_GetSocketError(GWEN_SOCKET *sp);
361 
371  int GWEN_Socket_SetReuseAddress(GWEN_SOCKET *sp, int fl);
386 int GWEN_Socket_GetSocketInt(const GWEN_SOCKET *sp);
387 
388 /* end of group socket */
391 /* end of group socketsandsets */
394 #ifdef __cplusplus
395 }
396 #endif
397 
398 #endif /* GWEN_SOCKET_H */
399 
400 
401