00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef _FETCP_INCLUDE_H
00031 #define _FETCP_INCLUDE_H
00032
00033
00034 #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_CVI_)
00035 #ifdef FETCPDLL
00036 #define DLL_EXT_FUNC __declspec(dllexport) __stdcall
00037 #else
00038 #define DLL_EXT_FUNC __declspec(dllimport) __stdcall
00039 #endif
00040 #define FETCP_EXT_CALL __stdcall
00041 #define FETCP_CALL __cdecl
00042 #else
00043 #define DLL_EXT_FUNC
00044 #define CALLBACK
00045 #define FETCP_EXT_CALL
00046 #define FETCP_CALL
00047 #endif
00048
00049
00050
00051 #ifdef __GNUC__
00052 #ifndef __int64
00053 #define __int64 long long
00054 #endif
00055 #endif
00056
00057
00058
00059 #ifdef __cplusplus
00060 extern "C" {
00061 #endif
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073 #define FETCP_ERR_NEWSOCKET_FAILURE -1200
00074 #define FETCP_ERR_EMPTY_LIST -1201
00075 #define FETCP_ERR_POINTER_IS_NULL -1202
00076 #define FETCP_ERR_NO_MEMORY -1203
00077 #define FETCP_ERR_SERVER_NOT_FOUND -1205
00078
00079
00080 #define FETCP_ERR_NO_CONNECTION -1211
00081 #define FETCP_ERR_SERVER_ADDR -1212 // Wenn Hostname nicht aufgelöst werden kann
00082 #define FETCP_ERR_CLOSE_CONNECTION -1213
00083
00084
00085 #define FETCP_ERR_UNKNOWN_HND -1220
00086 #define FETCP_ERR_HND_IS_NULL -1221
00087 #define FETCP_ERR_HND_IS_NEGATIVE -1222
00088 #define FETCP_ERR_NO_HND_FOUND -1223
00089
00090
00091 #define FETCP_ERR_TIMEOUT -1230
00092 #define FETCP_ERR_RECEIVE_PROCESS -1232
00093 #define FETCP_ERR_CHANGE_SOCKET_PARA -1236
00094 #define FETCP_ERR_TRANSMIT_PROCESS -1237
00095 #define FETCP_ERR_GET_CONNECTION_STATE -1238
00096
00097
00098 #define FETCP_ERR_UNKNOWN_PARAMETER -1250
00099 #define FETCP_ERR_PARAMETER_OUT_OF_RANGE -1251
00100 #define FETCP_ERR_ODD_PARAMETERSTRING -1252
00101 #define FETCP_ERR_UNKNOWN_ERRORCODE -1254
00102
00103
00104 #define FETCP_ERR_BUFFER_OVERFLOW -1270
00105
00106
00107
00108
00109
00110
00111 #define FETCP_GET_DLL_VERSION 1200
00112 #define FETCP_GET_ERROR_TEXT 1201
00113 #define FETCP_GET_LAST_ERROR 1202
00114
00115
00116 #define FETCP_ADD_EVENT_HANDLER 1210
00117 #define FETCP_DEL_EVENT_HANDLER 1211
00118
00119
00120 #define FETCP_DETECT 1220
00121 #define FETCP_CONNECT 1221
00122 #define FETCP_DISCONNECT 1222
00123 #define FETCP_GET_SOCKET_LIST 1223
00124 #define FETCP_GET_SOCKET_PARA 1224
00125 #define FETCP_SET_SOCKET_PARA 1225
00126 #define FETCP_GET_SOCKET_HND 1226
00127 #define FETCP_GET_SOCKET_STATE 1227
00128
00129
00130 #define FETCP_TRANSCEIVE 1230
00131 #define FETCP_TRANSMIT 1231
00132 #define FETCP_RECEIVE 1232
00133
00134
00135
00136 #define FETCP_STATE_CLOSED 1 // X X
00137 #define FETCP_STATE_LISTEN 2 // X X
00138 #define FETCP_STATE_SYN_SENT 3 // X X
00139 #define FETCP_STATE_SYN_RCVD 4 // X X
00140 #define FETCP_STATE_ESTABLISHED 5 // X X
00141 #define FETCP_STATE_FIN_WAIT1 6 // X X
00142 #define FETCP_STATE_FIN_WAIT2 7 // X X
00143 #define FETCP_STATE_CLOSE_WAIT 8 // X X
00144 #define FETCP_STATE_CLOSING 9 // X X
00145 #define FETCP_STATE_LAST_ACK 10 // X X
00146 #define FETCP_STATE_TIME_WAIT 11 // X -
00147 #define FETCP_STATE_DELETE_TCB 12 // X -
00148
00149
00150
00151
00152 #define FETCP_THREAD_ID 1
00153 #define FETCP_WND_HWND 2
00154 #define FETCP_CALLBACK 3
00155
00156
00157 #define FETCP_DEV_DISCONNECT_EVENT 2
00158
00159
00160
00161
00162
00163
00164
00165
00166 typedef struct _FETCP_EVENT_INIT
00167 {
00168 void* pAny;
00169
00170
00171 unsigned int uiUse;
00172 unsigned int uiMsg;
00173 unsigned int uiFlag;
00174 union
00175 {
00176 #if defined(_MSC_VER) || defined(__BORLANDC__)
00177 DWORD dwThreadID;
00178 HWND hwndWnd;
00179 #endif
00180
00181 void (FETCP_CALL* cbFct1)( void* pAny,
00182 int iSocketHnd,
00183 unsigned int uiUse,
00184 int iValue );
00185 #ifdef __cplusplus
00186 };
00187 #else
00188 }Method;
00189 #endif
00190
00191 } FETCP_EVENT_INIT;
00192
00193
00194
00195
00196
00197
00198
00199
00200 void DLL_EXT_FUNC FETCP_GetDLLVersion( char* cVersion );
00201 int DLL_EXT_FUNC FETCP_GetErrorText( int iErrorCode, char* cErrorText );
00202 int DLL_EXT_FUNC FETCP_GetLastError( int iSocketHnd, int* iErrorCode, char* cErrorText );
00203 int DLL_EXT_FUNC FETCP_Detect( char* cHostAdr, int iPortNr );
00204 int DLL_EXT_FUNC FETCP_GetSocketState( char* cHostAdr, int iPortNr );
00205
00206
00207 int DLL_EXT_FUNC FETCP_AddEventHandler(int iSocketHnd, FETCP_EVENT_INIT* pInit);
00208 int DLL_EXT_FUNC FETCP_DelEventHandler(int iSocketHnd, FETCP_EVENT_INIT* pInit);
00209
00210
00211 int DLL_EXT_FUNC FETCP_Connect( char* cHostAdr, int iPortNr );
00212 int DLL_EXT_FUNC FETCP_DisConnect( int iSocketHnd );
00213
00214
00215 int DLL_EXT_FUNC FETCP_GetSocketList( int iNext );
00216 int DLL_EXT_FUNC FETCP_GetSocketPara( int iSocketHnd, char* cPara, char* cValue );
00217 int DLL_EXT_FUNC FETCP_SetSocketPara( int iSocketHnd, char* cPara, char* cValue );
00218 int DLL_EXT_FUNC FETCP_GetSocketHnd( char* cHostAdr, int iPortNr );
00219
00220
00221 int DLL_EXT_FUNC FETCP_Transceive( int iSocketHnd, unsigned char* cSendProt, int iSendLen, unsigned char* cRecProt, int iRecLen );
00222 int DLL_EXT_FUNC FETCP_Transmit( int iSocketHnd, unsigned char* cSendProt, int iSendLen );
00223 int DLL_EXT_FUNC FETCP_Receive( int iSocketHnd, unsigned char* cRecProt, int iRecLen );
00224
00225
00226 #undef DLL_EXT_FUNC
00227
00228 #ifdef __cplusplus
00229 }
00230 #endif
00231
00232
00233
00234
00235
00236
00237
00238 typedef void (CALLBACK* LPFN_FETCP_GET_DLL_VERSION)(char*);
00239 typedef int (CALLBACK* LPFN_FETCP_GET_ERROR_TEXT)(int, char*);
00240 typedef int (CALLBACK* LPFN_FETCP_GET_LAST_ERROR)(int, int*, char*);
00241
00242
00243 typedef int (CALLBACK* LPFN_FETCP_ADD_EVENT_HANDLER)(int, FETCP_EVENT_INIT*);
00244 typedef int (CALLBACK* LPFN_FETCP_DEL_EVENT_HANDLER)(int, FETCP_EVENT_INIT*);
00245
00246
00247 typedef int (CALLBACK* LPFN_FETCP_DETECT)(char*, int);
00248 typedef int (CALLBACK* LPFN_FETCP_CONNECT)(char*, int);
00249 typedef int (CALLBACK* LPFN_FETCP_DISCONNECT)(int);
00250 typedef int (CALLBACK* LPFN_FETCP_GET_SOCKET_STATE)(char*, int);
00251 typedef int (CALLBACK* LPFN_FETCP_GET_SOCKET_LIST)(int);
00252 typedef int (CALLBACK* LPFN_FETCP_GET_SOCKET_PARA)(int, char*, char*);
00253 typedef int (CALLBACK* LPFN_FETCP_SET_SOCKET_PARA)(int, char*, char*);
00254 typedef int (CALLBACK* LPFN_FETCP_GET_SOCKET_HND)(char*, int);
00255
00256
00257 typedef int (CALLBACK* LPFN_FETCP_TRANSCEIVE)(int, unsigned char*, int, unsigned char*, int);
00258 typedef int (CALLBACK* LPFN_FETCP_TRANSMIT)(int, unsigned char*, int);
00259 typedef int (CALLBACK* LPFN_FETCP_RECEIVE)(int, unsigned char*, int);
00260
00261 #endif // _FETCP_INCLUDE_H