inetsocket.h
Go to the documentation of this file.
/***************************************************************************
begin : Tue Oct 02 2002
copyright : (C) 2002 by Martin Preuss
email : martin@libchipcard.de
***************************************************************************
* *
* This library 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. *
* *
* This library 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 library; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
* MA 02111-1307 USA *
* *
***************************************************************************/
#ifndef GWEN_SOCKET_H
#define GWEN_SOCKET_H
#include <gwenhywfar/gwenhywfarapi.h>
#include <gwenhywfar/error.h>
#include <gwenhywfar/inetaddr.h>
#include <gwenhywfar/list1.h>
#include <gwenhywfar/list2.h>
#define GWEN_SOCKET_FLAGS_DUMP_READ 0x00000001
#define GWEN_SOCKET_FLAGS_DUMP_WRITE 0x00000002
typedef struct GWEN_SOCKET GWEN_SOCKET;
typedef struct GWEN_SOCKETSETSTRUCT GWEN_SOCKETSET;
GWEN_LIST_FUNCTION_LIB_DEFS(GWEN_SOCKET, GWEN_Socket, GWENHYWFAR_API)
GWEN_LIST2_FUNCTION_LIB_DEFS(GWEN_SOCKET, GWEN_Socket, GWENHYWFAR_API)
#ifdef __cplusplus
extern "C" {
#endif
/*@TODO: remove this */
#define GWEN_SOCKET_ERROR_TYPE "Socket"
#define GWEN_SOCKET_ERROR_BAD_SOCKETTYPE (-1)
#define GWEN_SOCKET_ERROR_NOT_OPEN (-2)
#define GWEN_SOCKET_ERROR_TIMEOUT (-3)
#define GWEN_SOCKET_ERROR_IN_PROGRESS (-4)
#define GWEN_SOCKET_ERROR_STARTUP (-5)
#define GWEN_SOCKET_ERROR_INTERRUPTED (-6)
#define GWEN_SOCKET_ERROR_UNSUPPORTED (-7)
#define GWEN_SOCKET_ERROR_ABORTED (-8)
#define GWEN_SOCKET_ERROR_BROKEN_PIPE (-9)
typedef enum {
GWEN_SocketTypeTCP=1,
GWEN_SocketTypeUDP,
GWEN_SocketTypeRAW,
GWEN_SocketTypeUnix,
GWEN_SocketTypeFile
}
GWEN_SOCKETTYPE;
GWENHYWFAR_API GWEN_SOCKETSET *GWEN_SocketSet_new(void);
GWENHYWFAR_API void GWEN_SocketSet_free(GWEN_SOCKETSET *ssp);
GWENHYWFAR_API int GWEN_SocketSet_Clear(GWEN_SOCKETSET *ssp);
GWENHYWFAR_API
int GWEN_SocketSet_AddSocket(GWEN_SOCKETSET *ssp,
const GWEN_SOCKET *sp);
GWENHYWFAR_API
int GWEN_SocketSet_RemoveSocket(GWEN_SOCKETSET *ssp,
const GWEN_SOCKET *sp);
GWENHYWFAR_API int GWEN_SocketSet_HasSocket(GWEN_SOCKETSET *ssp,
const GWEN_SOCKET *sp);
GWENHYWFAR_API int GWEN_SocketSet_GetSocketCount(GWEN_SOCKETSET *ssp);
/*end of group socketset */
GWENHYWFAR_API GWEN_SOCKET *GWEN_Socket_new(GWEN_SOCKETTYPE socketType);
GWENHYWFAR_API GWEN_SOCKET *GWEN_Socket_fromFile(int fd);
GWENHYWFAR_API void GWEN_Socket_free(GWEN_SOCKET *sp);
GWENHYWFAR_API int GWEN_Socket_Open(GWEN_SOCKET *sp);
GWENHYWFAR_API int GWEN_Socket_Close(GWEN_SOCKET *sp);
GWENHYWFAR_API
int GWEN_Socket_Connect(GWEN_SOCKET *sp, const GWEN_INETADDRESS *addr);
GWENHYWFAR_API
int GWEN_Socket_Bind(GWEN_SOCKET *sp, const GWEN_INETADDRESS *addr);
GWENHYWFAR_API int GWEN_Socket_Listen(GWEN_SOCKET *sp, int backlog);
GWENHYWFAR_API
int GWEN_Socket_Accept(GWEN_SOCKET *sp,
GWEN_INETADDRESS **addr,
GWEN_SOCKET **newsock);
GWENHYWFAR_API GWEN_SOCKETTYPE GWEN_Socket_GetSocketType(GWEN_SOCKET *sp);
GWENHYWFAR_API
int GWEN_Socket_GetPeerAddr(GWEN_SOCKET *sp,
GWEN_INETADDRESS **addr);
GWENHYWFAR_API uint32_t GWEN_Socket_GetFlags(const GWEN_SOCKET *sp);
GWENHYWFAR_API void GWEN_Socket_AddFlags(GWEN_SOCKET *sp, uint32_t f);
GWENHYWFAR_API void GWEN_Socket_SubFlags(GWEN_SOCKET *sp, uint32_t f);
GWENHYWFAR_API
int GWEN_Socket_Select(GWEN_SOCKETSET *rs,
GWEN_SOCKETSET *ws,
GWEN_SOCKETSET *xs,
int timeout);
GWENHYWFAR_API
int GWEN_Socket_WaitForRead(GWEN_SOCKET *sp, int timeout);
GWENHYWFAR_API
int GWEN_Socket_WaitForWrite(GWEN_SOCKET *sp, int timeout);
GWENHYWFAR_API int GWEN_Socket_Read(GWEN_SOCKET *sp,
char *buffer,
int *bsize);
GWENHYWFAR_API int GWEN_Socket_Write(GWEN_SOCKET *sp,
const char *buffer,
int *bsize);
GWENHYWFAR_API
int GWEN_Socket_ReadFrom(GWEN_SOCKET *sp,
GWEN_INETADDRESS **addr,
char *buffer,
int *bsize);
GWENHYWFAR_API
int GWEN_Socket_WriteTo(GWEN_SOCKET *sp,
const GWEN_INETADDRESS *addr,
const char *buffer,
int *bsize);
GWENHYWFAR_API int GWEN_Socket_SetBlocking(GWEN_SOCKET *sp, int fl);
GWENHYWFAR_API int GWEN_Socket_SetBroadcast(GWEN_SOCKET *sp, int fl);
GWENHYWFAR_API int GWEN_Socket_GetSocketError(GWEN_SOCKET *sp);
GWENHYWFAR_API
int GWEN_Socket_SetReuseAddress(GWEN_SOCKET *sp, int fl);
GWENHYWFAR_API
int GWEN_Socket_GetSocketInt(const GWEN_SOCKET *sp);
/* end of group socket */
/* end of group socketsandsets */
#ifdef __cplusplus
}
#endif
#endif /* GWEN_SOCKET_H */
error.h
GWEN_SOCKETTYPE
GWEN_SOCKETTYPE
Definition inetsocket.h:83
GWEN_SocketTypeUDP
@ GWEN_SocketTypeUDP
Definition inetsocket.h:85
GWEN_SocketTypeRAW
@ GWEN_SocketTypeRAW
Definition inetsocket.h:86
GWEN_SocketTypeTCP
@ GWEN_SocketTypeTCP
Definition inetsocket.h:84
GWEN_SocketTypeUnix
@ GWEN_SocketTypeUnix
Definition inetsocket.h:87
GWEN_SocketTypeFile
@ GWEN_SocketTypeFile
Definition inetsocket.h:88
GWEN_Socket_free
GWENHYWFAR_API void GWEN_Socket_free(GWEN_SOCKET *sp)
GWEN_SocketSet_GetSocketCount
GWENHYWFAR_API int GWEN_SocketSet_GetSocketCount(GWEN_SOCKETSET *ssp)
GWEN_Socket_Close
GWENHYWFAR_API int GWEN_Socket_Close(GWEN_SOCKET *sp)
GWEN_Socket_Open
GWENHYWFAR_API int GWEN_Socket_Open(GWEN_SOCKET *sp)
GWEN_Socket_fromFile
GWENHYWFAR_API GWEN_SOCKET * GWEN_Socket_fromFile(int fd)
GWEN_Socket_new
GWENHYWFAR_API GWEN_SOCKET * GWEN_Socket_new(GWEN_SOCKETTYPE socketType)
GWEN_SocketSet_HasSocket
GWENHYWFAR_API int GWEN_SocketSet_HasSocket(GWEN_SOCKETSET *ssp, const GWEN_SOCKET *sp)
GWEN_SocketSet_RemoveSocket
GWENHYWFAR_API int GWEN_SocketSet_RemoveSocket(GWEN_SOCKETSET *ssp, const GWEN_SOCKET *sp)
GWEN_SocketSet_free
GWENHYWFAR_API void GWEN_SocketSet_free(GWEN_SOCKETSET *ssp)
GWEN_SocketSet_Clear
GWENHYWFAR_API int GWEN_SocketSet_Clear(GWEN_SOCKETSET *ssp)
GWEN_SocketSet_AddSocket
GWENHYWFAR_API int GWEN_SocketSet_AddSocket(GWEN_SOCKETSET *ssp, const GWEN_SOCKET *sp)
GWEN_SocketSet_new
GWENHYWFAR_API GWEN_SOCKETSET * GWEN_SocketSet_new(void)
GWEN_Socket_Read
GWENHYWFAR_API int GWEN_Socket_Read(GWEN_SOCKET *sp, char *buffer, int *bsize)
GWEN_Socket_GetPeerAddr
GWENHYWFAR_API int GWEN_Socket_GetPeerAddr(GWEN_SOCKET *sp, GWEN_INETADDRESS **addr)
GWEN_Socket_Accept
GWENHYWFAR_API int GWEN_Socket_Accept(GWEN_SOCKET *sp, GWEN_INETADDRESS **addr, GWEN_SOCKET **newsock)
GWEN_Socket_Bind
GWENHYWFAR_API int GWEN_Socket_Bind(GWEN_SOCKET *sp, const GWEN_INETADDRESS *addr)
GWEN_Socket_SetBlocking
GWENHYWFAR_API int GWEN_Socket_SetBlocking(GWEN_SOCKET *sp, int fl)
GWEN_Socket_SetBroadcast
GWENHYWFAR_API int GWEN_Socket_SetBroadcast(GWEN_SOCKET *sp, int fl)
GWEN_Socket_SubFlags
GWENHYWFAR_API void GWEN_Socket_SubFlags(GWEN_SOCKET *sp, uint32_t f)
GWEN_Socket_GetSocketType
GWENHYWFAR_API GWEN_SOCKETTYPE GWEN_Socket_GetSocketType(GWEN_SOCKET *sp)
GWEN_Socket_GetSocketInt
GWENHYWFAR_API int GWEN_Socket_GetSocketInt(const GWEN_SOCKET *sp)
GWEN_Socket_SetReuseAddress
GWENHYWFAR_API int GWEN_Socket_SetReuseAddress(GWEN_SOCKET *sp, int fl)
GWEN_Socket_Listen
GWENHYWFAR_API int GWEN_Socket_Listen(GWEN_SOCKET *sp, int backlog)
GWEN_Socket_Connect
GWENHYWFAR_API int GWEN_Socket_Connect(GWEN_SOCKET *sp, const GWEN_INETADDRESS *addr)
GWEN_Socket_WriteTo
GWENHYWFAR_API int GWEN_Socket_WriteTo(GWEN_SOCKET *sp, const GWEN_INETADDRESS *addr, const char *buffer, int *bsize)
GWEN_Socket_WaitForRead
GWENHYWFAR_API int GWEN_Socket_WaitForRead(GWEN_SOCKET *sp, int timeout)
GWEN_Socket_ReadFrom
GWENHYWFAR_API int GWEN_Socket_ReadFrom(GWEN_SOCKET *sp, GWEN_INETADDRESS **addr, char *buffer, int *bsize)
GWEN_Socket_WaitForWrite
GWENHYWFAR_API int GWEN_Socket_WaitForWrite(GWEN_SOCKET *sp, int timeout)
GWEN_Socket_GetSocketError
GWENHYWFAR_API int GWEN_Socket_GetSocketError(GWEN_SOCKET *sp)
GWEN_Socket_GetFlags
GWENHYWFAR_API uint32_t GWEN_Socket_GetFlags(const GWEN_SOCKET *sp)
GWEN_Socket_Select
GWENHYWFAR_API int GWEN_Socket_Select(GWEN_SOCKETSET *rs, GWEN_SOCKETSET *ws, GWEN_SOCKETSET *xs, int timeout)
GWEN_Socket_AddFlags
GWENHYWFAR_API void GWEN_Socket_AddFlags(GWEN_SOCKET *sp, uint32_t f)
GWEN_Socket_Write
GWENHYWFAR_API int GWEN_Socket_Write(GWEN_SOCKET *sp, const char *buffer, int *bsize)
gwenhywfarapi.h
GWENHYWFAR_API
#define GWENHYWFAR_API
Definition gwenhywfarapi.h:67
inetaddr.h
This file contains the internet address handling module.
GWEN_INETADDRESS
struct GWEN_INETADDRESSSTRUCT GWEN_INETADDRESS
Definition inetaddr.h:95
GWEN_SOCKETSET
struct GWEN_SOCKETSETSTRUCT GWEN_SOCKETSET
Definition inetsocket.h:45
GWEN_SOCKET
struct GWEN_SOCKET GWEN_SOCKET
Definition inetsocket.h:44
list1.h
GWEN_LIST_FUNCTION_LIB_DEFS
#define GWEN_LIST_FUNCTION_LIB_DEFS(t, pr, decl)
Definition list1.h:349
list2.h
This file contains some macros concerning lists.
GWEN_LIST2_FUNCTION_LIB_DEFS
#define GWEN_LIST2_FUNCTION_LIB_DEFS(t, pr, decl)
Definition list2.h:56