ZFFramework
 
Loading...
Searching...
No Matches
ZFTcp.h
Go to the documentation of this file.
1
5
6#ifndef _ZFI_ZFTcp_h_
7#define _ZFI_ZFTcp_h_
8
9#include "ZFNetDef.h"
11
16 ZFENUM_VALUE(Invalid)
17 ZFENUM_VALUE(Server)
18 ZFENUM_VALUE(Client)
19 ZFENUM_VALUE(ServerAccept)
24 ZFENUM_VALUE_REGISTER(ServerAccept)
27
28zfclassFwd _ZFP_ZFTcpPrivate;
29// ============================================================
33zfclass ZFLIB_ZFNet ZFTcp : zfextend ZFObject {
34 ZFOBJECT_DECLARE(ZFTcp, ZFObject)
35
36public:
49 , ZFMP_IN(const zfstring &, host)
51 , ZFMP_IN_OPT(zftimet, timeout, -1)
52 )
59
64
69
78
83 , ZFMP_IN_OUT(zfstring &, remoteAddr)
84 )
89
90public:
103 , ZFMP_IN_OPT(zftimet, timeout, -1)
105
106 // ============================================================
107public:
116 , ZFMP_IN(const zfstring &, data)
126 , ZFMP_IN(const void *, data)
127 , ZFMP_IN(zfindex, size)
137 , ZFMP_IN(const ZFInput &, input)
139
140 // ============================================================
141public:
157 , ZFMP_IN_OUT(zfstring &, data)
158 , ZFMP_IN_OPT(zfindex, maxSize, zfindexMax())
159 , ZFMP_IN_OPT(zftimet, timeout, -1)
176 , ZFMP_IN_OUT(const ZFOutput &, output)
177 , ZFMP_IN_OPT(zfindex, maxSize, zfindexMax())
178 , ZFMP_IN_OPT(zftimet, timeout, -1)
180
181public:
184
185protected:
187 virtual void objectOnInit(void);
189 virtual void objectOnDealloc(void);
191 virtual void objectOnDeallocPrepare(void);
192
193private:
194 _ZFP_ZFTcpPrivate *d;
195};
196
198#endif // #ifndef _ZFI_ZFTcp_h_
199
#define zfextend
dummy macro shows class inherit from another
Definition ZFCoreTypeDef_ClassType.h:53
#define zfoverride
dummy macro shows that method override parent's method
Definition ZFCoreTypeDef_ClassType.h:58
#define ZF_IN_OUT
dummy macro that shows the param used as required input and output
Definition ZFCoreTypeDef_ClassType.h:196
#define zfclassFwd
forward declaration of a class type
Definition ZFCoreTypeDef_ClassType.h:31
_ZFT_t_zfbool zfbool
bool type
Definition ZFCoreTypeDef_CoreType.h:103
_ZFT_t_zfindex zfindex
similar to size_t, used for index and size only
Definition ZFCoreTypeDef_CoreType.h:154
_zft_zftimet zftimet
time unit, ensured at least 64 bit, ensured signed
Definition ZFCoreTypeDef_CoreType.h:203
#define zfindexMax()
(zfindex)-1, indicate a max index value, see zfindex
Definition ZFCoreTypeDef_CoreType.h:159
_ZFT_t_zfuint zfuint
same as unsigned int, see zfindex
Definition ZFCoreTypeDef_CoreType.h:169
zft_zfstring< zfchar > zfstring
see zft_zfstring
Definition ZFCoreTypeDef_StringType.h:15
#define ZFENUM_SEPARATOR()
see ZFENUM_BEGIN
Definition ZFEnumDeclare.h:158
#define ZFENUM_VALUE_REGISTER(Value)
see ZFENUM_BEGIN
Definition ZFEnumDeclare.h:168
#define ZFENUM_REG(ZFLIB_, EnumName,...)
see ZFENUM_BEGIN
Definition ZFEnumDeclare.h:186
#define ZFENUM_VALUE(Value)
see ZFENUM_BEGIN
Definition ZFEnumDeclare.h:151
#define ZFENUM_BEGIN(ZFLIB_, EnumName)
macros to define reflectable enum type
Definition ZFEnumDeclare.h:147
#define ZFENUM_END(ZFLIB_, EnumName)
see ZFENUM_BEGIN
Definition ZFEnumDeclare.h:172
#define ZFMP_IN_OUT(ParamType, paramName)
see ZFMP_IN
Definition ZFMethod.h:117
#define ZFMP_IN_OPT(ParamType, paramName, DefaultValue)
see ZFMP_IN
Definition ZFMethod.h:108
#define ZFMP_IN(ParamType, paramName)
macro to wrap param types for ZFMETHOD_INLINE_0 series
Definition ZFMethod.h:105
#define ZFMETHOD_DECLARE_0(ReturnType, MethodName)
see ZFMethod
Definition ZFMethodDeclare.h:693
#define ZFMETHOD_DECLARE_2(ReturnType, MethodName, ZFMP_0, ZFMP_1)
see ZFMethod
Definition ZFMethodDeclare.h:1025
#define ZFMETHOD_DECLARE_3(ReturnType, MethodName, ZFMP_0, ZFMP_1, ZFMP_2)
see ZFMethod
Definition ZFMethodDeclare.h:1206
#define ZFMETHOD_DECLARE_1(ReturnType, MethodName, ZFMP_0)
see ZFMethod
Definition ZFMethodDeclare.h:854
#define ZF_NAMESPACE_GLOBAL_BEGIN
begin namespace ZFFramework
Definition ZFNamespace.h:97
#define ZF_NAMESPACE_GLOBAL_END
end namespace ZFFramework
Definition ZFNamespace.h:98
global header for ZFNet module
#define ZFLIB_ZFNet
used to export symbols
Definition ZFNetDef.h:15
#define zfclass
same as class, shows that this class is a ZFObject type
Definition ZFObjectClassTypeFwd.h:38
#define ZFOBJECT_DECLARE(ChildClass, SuperClass,...)
necessary for every class inherit from ZFObject
Definition ZFObjectDeclare.h:126
v_ZFTcpType::ZFEnumType ZFTcpType
see v_ZFTcpType
Definition ZFTcp.h:25
general input callback
Definition ZFIOCallback_input.h:37
general output callback
Definition ZFIOCallback_output.h:37
virtual void close()
close the socket, see open
virtual zfindex recv(zfstring &data, zfindex maxSize=(((zfindex) -1)), zftimet timeout=(-1))
recv packet until timeout
virtual zfuint port()
current opened port, passed from open
virtual ZFTcpType type()
type of this tcp object
virtual void objectOnInit(void)
override this to init your object
virtual zfautoT< ZFTcp > accept(zftimet timeout=(-1))
start accept client connection
virtual zfstring remoteInfo()
get remote addr, always fail if current type is v_ZFTcpType::e_Invalid or v_ZFTcpType::e_Server
virtual zfbool valid()
true if open or accept successfully
virtual void objectInfoImpl(zfstring &ret)
see objectInfo
virtual zfbool send(const zfstring &data)
send packet
virtual void objectOnDealloc(void)
override this to destroy your object
virtual zfbool open(const zfstring &host, zfuint port, zftimet timeout=(-1))
open a socket with specified host and port
virtual void objectOnDeallocPrepare(void)
called before objectOnDealloc, safe to call virtual functions here
virtual const zfstring & host()
current opened port, passed from open
virtual zfbool remoteInfoT(zfstring &remoteAddr)
get remote addr, always fail if current type is v_ZFTcpType::e_Invalid or v_ZFTcpType::e_Server
type restrict version of zfauto
Definition zfautoFwd.h:110