# netconnection.h File Reference

`#include <gwenhywfar/gwenhywfarapi.h>`
`#include <gwenhywfar/misc.h>`
`#include <gwenhywfar/inherit.h>`
`#include <gwenhywfar/nettransport.h>`
`#include <gwenhywfar/netmsg.h>`
`#include <gwenhywfar/ringbuffer.h>`

Go to the source code of this file.

## Special Timeout Values

These special timeout values can be used whenever a timeout parameter is expected. Positive timeout values specify a limit for the number of seconds to wait.
#define | GWEN_NETCONNECTION_TIMEOUT_FOREVER (-1)
#define | GWEN_NETCONNECTION_TIMEOUT_NONE (0)

## Wait Flags

These flags are used with GWEN_NetConnection_Wait.
#define | GWEN_NETCONNECTION_WAIT_READ 0x0001
#define | GWEN_NETCONNECTION_WAIT_WRITE 0x0002

## Prototypes For Virtual Functions

typedef GWEN_TYPE_UINT32(* | GWEN_NETCONNECTION_CHECKFN )(GWEN_NETCONNECTION *conn)
typedef void(* | GWEN_NETCONNECTION_DOWNFN )(GWEN_NETCONNECTION *conn)
typedef void(* | GWEN_NETCONNECTION_UPFN )(GWEN_NETCONNECTION *conn)
typedef GWEN_NETCONNECTION_WORKRESULT(* | GWEN_NETCONNECTION_WORKFN )(GWEN_NETCONNECTION *conn)

## Inheritance API

Functions in this group are meant to be called by inheriting "classes". These functions MUST NOT be called by programs. You must define GWEN_EXTEND_NETCONNECTION prior to including this header file in order to have these functions defined.
GWENHYWFAR_API void | GWEN_NetConnection_AddInMsg (GWEN_NETCONNECTION *conn, GWEN_NETMSG *msg)
GWENHYWFAR_API GWEN_NETMSG * | GWEN_NetConnection_GetOutMsg (GWEN_NETCONNECTION *conn)
GWENHYWFAR_API GWEN_RINGBUFFER * | GWEN_NetConnection_GetReadBuffer (GWEN_NETCONNECTION *conn)
GWENHYWFAR_API GWEN_RINGBUFFER * | GWEN_NetConnection_GetWriteBuffer (GWEN_NETCONNECTION *conn)
GWENHYWFAR_API GWEN_NETMSG * | GWEN_NetConnection_PeekOutMsg (const GWEN_NETCONNECTION *conn)

## Message Related Functions

GWENHYWFAR_API void | GWEN_NetConnection_AddOutMsg (GWEN_NETCONNECTION *conn, GWEN_NETMSG *msg)
GWENHYWFAR_API GWEN_NETMSG * | GWEN_NetConnection_GetInMsg (GWEN_NETCONNECTION *conn)
GWENHYWFAR_API GWEN_NETMSG * | GWEN_NetConnection_GetInMsg_Wait (GWEN_NETCONNECTION *conn, int timeout)
GWENHYWFAR_API GWEN_NETMSG * | GWEN_NetConnection_PeekInMsg (const GWEN_NETCONNECTION *conn)

## Constructor And Destructor

GWENHYWFAR_API void | GWEN_NetConnection_Attach (GWEN_NETCONNECTION *conn)
GWENHYWFAR_API void | GWEN_NetConnection_free (GWEN_NETCONNECTION *conn)
GWENHYWFAR_API GWEN_NETCONNECTION * | GWEN_NetConnection_new (GWEN_NETTRANSPORT *tr, int take, GWEN_TYPE_UINT32 libId)

## Opening, Closing And Listening

GWENHYWFAR_API int | GWEN_NetConnection_Connect_Wait (GWEN_NETCONNECTION *conn, int timeout)
GWENHYWFAR_API int | GWEN_NetConnection_Disconnect_Wait (GWEN_NETCONNECTION *conn, int timeout)
GWENHYWFAR_API GWEN_NETTRANSPORT * | GWEN_NetConnection_GetNextIncoming (GWEN_NETCONNECTION *conn)
GWENHYWFAR_API GWEN_NETTRANSPORT * | GWEN_NetConnection_GetNextIncoming_Wait (GWEN_NETCONNECTION *conn, int timeout)
GWENHYWFAR_API int | GWEN_NetConnection_StartConnect (GWEN_NETCONNECTION *conn)
GWENHYWFAR_API int | GWEN_NetConnection_StartDisconnect (GWEN_NETCONNECTION *conn)
GWENHYWFAR_API int | GWEN_NetConnection_StartListen (GWEN_NETCONNECTION *conn)

## Virtual Functions

GWENHYWFAR_API void | GWEN_NetConnection_Down (GWEN_NETCONNECTION *conn)
GWENHYWFAR_API void | GWEN_NetConnection_Up (GWEN_NETCONNECTION *conn)
GWENHYWFAR_API GWEN_NETCONNECTION_WORKRESULT | GWEN_NetConnection_Work (GWEN_NETCONNECTION *conn)

## Reading And Writing

GWENHYWFAR_API int | GWEN_NetConnection_Flush (GWEN_NETCONNECTION *conn, int timeout)
GWENHYWFAR_API int | GWEN_NetConnection_Read (GWEN_NETCONNECTION *conn, char *buffer, GWEN_TYPE_UINT32 *bsize)
GWENHYWFAR_API int | GWEN_NetConnection_Read_Wait (GWEN_NETCONNECTION *conn, char *buffer, GWEN_TYPE_UINT32 *bsize, int timeout)
GWENHYWFAR_API int | GWEN_NetConnection_Write (GWEN_NETCONNECTION *conn, const char *buffer, GWEN_TYPE_UINT32 *bsize)
GWENHYWFAR_API int | GWEN_NetConnection_Write_Wait (GWEN_NETCONNECTION *conn, const char *buffer, GWEN_TYPE_UINT32 *bsize, int timeout)

## Informational Functions

GWENHYWFAR_API int | GWEN_NetConnection_GetDownAfterSend (GWEN_NETCONNECTION *conn)
GWENHYWFAR_API GWEN_TYPE_UINT32 | GWEN_NetConnection_GetFlags (const GWEN_NETCONNECTION *conn)
GWENHYWFAR_API double | GWEN_NetConnection_GetIdleTime (const GWEN_NETCONNECTION *conn)
GWENHYWFAR_API GWEN_TYPE_UINT32 | GWEN_NetConnection_GetLibraryMark (const GWEN_NETCONNECTION *conn)
GWENHYWFAR_API const GWEN_INETADDRESS * | GWEN_NetConnection_GetPeerAddr (const GWEN_NETCONNECTION *conn)
GWENHYWFAR_API GWEN_NETTRANSPORT_STATUS | GWEN_NetConnection_GetStatus (const GWEN_NETCONNECTION *conn)
GWENHYWFAR_API GWEN_NETTRANSPORT * | GWEN_NetConnection_GetTransportLayer (const GWEN_NETCONNECTION *conn)
GWENHYWFAR_API GWEN_TYPE_UINT32 | GWEN_NetConnection_GetUserMark (const GWEN_NETCONNECTION *conn)
GWENHYWFAR_API void | GWEN_NetConnection_Reset (GWEN_NETCONNECTION *conn)
GWENHYWFAR_API void | GWEN_NetConnection_SetDownAfterSend (GWEN_NETCONNECTION *conn, int i)
GWENHYWFAR_API void | GWEN_NetConnection_SetFlags (GWEN_NETCONNECTION *conn, GWEN_TYPE_UINT32 fl)
GWENHYWFAR_API void | GWEN_NetConnection_SetStatus (GWEN_NETCONNECTION *conn, GWEN_NETTRANSPORT_STATUS nst)
GWENHYWFAR_API void | GWEN_NetConnection_SetUserMark (GWEN_NETCONNECTION *conn, GWEN_TYPE_UINT32 m)

## Setters For Virtual Functions

GWENHYWFAR_API void | GWEN_NetConnection_SetCheckFn (GWEN_NETCONNECTION *conn, GWEN_NETCONNECTION_CHECKFN fn)
GWENHYWFAR_API void | GWEN_NetConnection_SetDownFn (GWEN_NETCONNECTION *conn, GWEN_NETCONNECTION_DOWNFN fn)
GWENHYWFAR_API void | GWEN_NetConnection_SetUpFn (GWEN_NETCONNECTION *conn, GWEN_NETCONNECTION_UPFN fn)
GWENHYWFAR_API void | GWEN_NetConnection_SetWorkFn (GWEN_NETCONNECTION *conn, GWEN_NETCONNECTION_WORKFN fn)

## Waiting And Working

GWENHYWFAR_API int | GWEN_NetConnection_WaitForStatus (GWEN_NETCONNECTION *conn, GWEN_NETTRANSPORT_STATUS expStatus, int timeout)
GWENHYWFAR_API GWEN_NETCONNECTION_WORKRESULT | GWEN_NetConnection_Walk (GWEN_NETCONNECTION_LIST *connList, int timeout)
GWENHYWFAR_API GWEN_NETCONNECTION_WORKRESULT | GWEN_NetConnection_WorkIO (GWEN_NETCONNECTION *conn)

## Defines

#define | GWEN_NETCONNECTION_CBID_IO "GWEN_NETCONNECTION_CBID_IO"
#define | GWEN_NETCONNECTION_CHECK_WANTREAD 0x0001
#define | GWEN_NETCONNECTION_CHECK_WANTWRITE 0x0002

## Typedefs

typedef GWEN_NETCONNECTION | GWEN_NETCONNECTION

## Enumerations

enum | GWEN_NETCONNECTION_WORKRESULT { GWEN_NetConnectionWorkResult_NoChange = 0, GWEN_NetConnectionWorkResult_Change, GWEN_NetConnectionWorkResult_Error }

## Functions

GWENHYWFAR_API void | GWEN_NetConnection_Dump (const GWEN_NETCONNECTION *conn)