Commit fffab4a7 by 李定达

1.天福dll

parents
fmdlltest/Release/
fmdlltest/Debug/
fmdll/Release/
fmdll/Debug/
*.sdf
fmdlltest/fmdlltest.vcxproj.user
*.vcxproj
*.filters
*.user

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fmdll", "fmdll\fmdll.vcxproj", "{3A8FED77-83D0-4167-8F64-D17090AD6111}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fmdlltest", "fmdlltest\fmdlltest.vcxproj", "{2080F357-1774-4F21-9C07-3CFFE4F9E74F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3A8FED77-83D0-4167-8F64-D17090AD6111}.Debug|Win32.ActiveCfg = Debug|Win32
{3A8FED77-83D0-4167-8F64-D17090AD6111}.Debug|Win32.Build.0 = Debug|Win32
{3A8FED77-83D0-4167-8F64-D17090AD6111}.Release|Win32.ActiveCfg = Release|Win32
{3A8FED77-83D0-4167-8F64-D17090AD6111}.Release|Win32.Build.0 = Release|Win32
{2080F357-1774-4F21-9C07-3CFFE4F9E74F}.Debug|Win32.ActiveCfg = Debug|Win32
{2080F357-1774-4F21-9C07-3CFFE4F9E74F}.Debug|Win32.Build.0 = Debug|Win32
{2080F357-1774-4F21-9C07-3CFFE4F9E74F}.Release|Win32.ActiveCfg = Release|Win32
{2080F357-1774-4F21-9C07-3CFFE4F9E74F}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
File added
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <direct.h>
#include <io.h>
#include <time.h>
#include <windows.h>
#include <winsock.h>
#include <DbgHelp.h>
#include "fmnetwork.h"
#pragma comment(lib, "ws2_32.lib")
EXTERN_C IMAGE_DOS_HEADER __ImageBase;
#define MAX_BUF_SIZE 25600
#define CFG_FILE_NAME "fmclientdll.cfg"
#define ROLL_BACK_FILE_NAME "fmclient.rbk"
#define LOG_FILE_NAME "fmclient"
#define MAX_LOG_LINE_NUM 1024
#define DIR_LOG "\\fmdlllog\\"
typedef struct
{
char ip[30];
int port;
SOCKET sock;
SOCKADDR_IN addr;
unsigned char shortTimeOut;
char path[MAX_PATH];
char sendBuf[MAX_BUF_SIZE];
char recvBuf[MAX_BUF_SIZE];
char tempBuf[MAX_BUF_SIZE];
char tmpBuf[MAX_BUF_SIZE];
char logFileName[MAX_PATH];
char procPath[MAX_PATH];
FILE * cfgFile;
FILE * logFile;
}clientInfo;
clientInfo g_clientInfo = { {0} };
void GetLogFileName(char * pathBuf, char * logPath)
{
char AbsolutePath[MAX_PATH] = {0};
struct tm *ptm;
time_t now;
time(&now);
ptm = gmtime(&now);
strcpy( AbsolutePath, pathBuf);
strcat(AbsolutePath, DIR_LOG);
mkdir( AbsolutePath);
sprintf(logPath, "%s%s%d%02d%02d.log", AbsolutePath, LOG_FILE_NAME, ptm->tm_year,ptm->tm_mon,ptm->tm_mday);
}
void logPrintf(char * logInfo, ...)
{
time_t now;
va_list arg_ptr;
time(&now);
//if (0 == g_clientInfo.logFile || MAX_LOG_LINE_NUM <= g_clientInfo.curLogLineIdx)
//{
// if (MAX_LOG_LINE_NUM <= g_clientInfo.curLogLineIdx)
// {
// fclose(g_clientInfo.logFile);
// g_clientInfo.logFile = 0;
// }
GetLogFileName(g_clientInfo.procPath, g_clientInfo.logFileName);
if(0 == access(g_clientInfo.logFileName, 0))
g_clientInfo.logFile = fopen(g_clientInfo.logFileName,"a+");
else
g_clientInfo.logFile = fopen(g_clientInfo.logFileName,"w");
//g_clientInfo.curLogLineIdx = 0;
//}
va_start(arg_ptr,logInfo);
vprintf(logInfo, arg_ptr);
vfprintf(g_clientInfo.logFile, ctime(&now), arg_ptr);
vfprintf(g_clientInfo.logFile, logInfo, arg_ptr);
fflush(g_clientInfo.logFile);
va_end(arg_ptr);
//g_clientInfo.curLogLineIdx++;
}
void GetProcPath(char * pathBuf)
{
int curPos;
GetModuleFileName((HMODULE)&__ImageBase, pathBuf, MAX_PATH);
curPos = strlen(pathBuf) - 1;
while('\\' != pathBuf[curPos])
{
curPos--;
}
curPos++;
pathBuf[curPos] = '\0';
}
int _stdcall initFmDll()
{
unsigned int value;
char dllPath[MAX_PATH] = {0};
int rlt;
WSADATA wsa_data;
int err;
char config[MAX_PATH] = "";
GetProcPath(dllPath);
if(strlen(dllPath) <= 0)
return -1;
strcpy(g_clientInfo.procPath, dllPath);
strcat(config, dllPath);
strcat(config, CFG_FILE_NAME);
g_clientInfo.cfgFile = fopen(config,"rt");
if(0 == g_clientInfo.cfgFile)
{
logPrintf("%s open cfg file failed!\r\n",config);
return -1;
}
rlt = fscanf(g_clientInfo.cfgFile, "%s", g_clientInfo.ip);
rlt = fscanf(g_clientInfo.cfgFile, "%u", &value);
g_clientInfo.port = value;
fclose(g_clientInfo.cfgFile);
err = WSAStartup(MAKEWORD(2, 0), &wsa_data);
return 0;
}
void _stdcall endFmDll()
{
if(g_clientInfo.sock > 0)
closesocket(g_clientInfo.sock);
fclose(g_clientInfo.logFile);
WSACleanup();
}
int checkIsCompleteJsonData(int * count, char * data)
{
int loop = 0;
while(data[loop])
{
if ('{' == data[loop])
{
(*count) ++;
}
if ('}' == data[loop])
{
(*count) --;
}
loop++;
if (0 == (*count))
{
break;
}
}
return loop;
}
int try2Connect2Clinent()
{
int rlt = 0;
unsigned long ul = 1;
fd_set fs;
struct timeval cntTO = {40,0};
int sockTimeOut = 40 * 1000;
g_clientInfo.sock = socket(AF_INET, SOCK_STREAM, 0);
g_clientInfo.addr.sin_addr.s_addr =inet_addr(g_clientInfo.ip);
g_clientInfo.addr.sin_family = AF_INET;
g_clientInfo.addr.sin_port = htons(g_clientInfo.port);
ioctlsocket(g_clientInfo.sock, FIONBIO, &ul);
connect(g_clientInfo.sock, (struct sockaddr *)&g_clientInfo.addr, sizeof(struct sockaddr));
//清除描述词组set的全部位
FD_ZERO(&fs);
FD_SET(g_clientInfo.sock, &fs);
rlt = select(g_clientInfo.sock + 1, 0, &fs, 0, &cntTO);
if (0 >= rlt)
{
return -1;
}
//设置为阻塞方式
ul = 0;
ioctlsocket(g_clientInfo.sock, FIONBIO, &ul);
//发送接收超时时间
setsockopt(g_clientInfo.sock, SOL_SOCKET, SO_SNDTIMEO, (char *)&sockTimeOut, sizeof(int));
setsockopt(g_clientInfo.sock, SOL_SOCKET, SO_RCVTIMEO, (char *)&sockTimeOut, sizeof(int));
return 0;
}
int ZH_caclChkValue(char * pJsonData, int startPos, int endPos)
{
int value = 0, loop = startPos, count = 0;
for (; loop < endPos; loop++)
{
if( pJsonData[loop] == '"' || pJsonData[loop] == '\'')
continue;
if (2 > count){
value += (int)pJsonData[loop];
}
else if (2 == count){
value *= (int)pJsonData[loop];
}else{
value -= (int)pJsonData[loop];
}
count = (count + 1) & 3;
}
return value;
}
void checkSendArray( char *_inJson)
{
int strLength;
int aLength ;
int nValue ;
strcpy(g_clientInfo.sendBuf, _inJson);
strLength = strlen(g_clientInfo.sendBuf);
while('}' != g_clientInfo.sendBuf[strLength - 1])
{
strLength--;
}
strLength--;
sprintf(g_clientInfo.sendBuf + strLength, ", \"checkValue\":");
aLength = strlen(g_clientInfo.sendBuf + strLength);
nValue = ZH_caclChkValue( g_clientInfo.sendBuf, 0, strLength + 2);
strLength += aLength;
sprintf(g_clientInfo.sendBuf + strLength, " %d", nValue);
aLength = strlen(g_clientInfo.sendBuf + strLength);
strLength += aLength;
g_clientInfo.sendBuf[strLength] = '}';
g_clientInfo.sendBuf[strLength + 1] = '\0';
}
int addCheckValueAndSendData2Sock()
{
int length = 0;
checkSendArray(g_clientInfo.sendBuf);
length = strlen(g_clientInfo.sendBuf);
if( length != send(g_clientInfo.sock, g_clientInfo.sendBuf, length, 0) )
{
closesocket(g_clientInfo.sock);
return -1;
}
logPrintf(g_clientInfo.sendBuf);
return 0;
}
int recvAndCheckDataFromSock()
{
int recbytes = 0;
int finLen = 0;
int checkCount = 0;
int tempLen = 0;
int recvLen = 0;
do
{
char * precvBuf;
if (0 >= (recbytes = recv(g_clientInfo.sock, g_clientInfo.recvBuf, (MAX_BUF_SIZE - 1), 0)))
{
return -1;
}
precvBuf = g_clientInfo.recvBuf;
g_clientInfo.recvBuf[recbytes] = '\0';
while(0 < recbytes)
{
finLen = checkIsCompleteJsonData(&checkCount, g_clientInfo.recvBuf + recvLen);
if (((0 == checkCount) && ('}' != g_clientInfo.recvBuf[ recvLen + finLen - 1])) || ((MAX_BUF_SIZE - 1) < tempLen + finLen))
{
return -1;
}
memcpy(g_clientInfo.tempBuf + tempLen, precvBuf + recvLen, finLen);
tempLen += finLen;
recvLen += finLen;
if (0 == checkCount)
{
g_clientInfo.tempBuf[tempLen] = '\0';
tempLen = 0;
checkCount = 0;
logPrintf("checkIsCompleteJsonData success !\n");
logPrintf("add:%p\n",g_clientInfo.recvBuf);
logPrintf("buf size:%d\n",strlen(g_clientInfo.recvBuf));
logPrintf("recv data:%s\n",g_clientInfo.recvBuf);
goto Exit;
}
recbytes -= finLen;
}
recvLen = 0;
}while(1);
Exit:
return 0;
}
int GBKToUTF8(unsigned char * lpGBKStr,int gbkLen, unsigned char * lpUTF8Str,int nUTF8StrLen)
{
wchar_t * lpUnicodeStr = NULL;
int nRetLen = 0;
if(!lpGBKStr) //如果GBK字符串为NULL则出错退出
return 0;
logPrintf("111111111111\n");
nRetLen = MultiByteToWideChar(CP_ACP,0,(char *)lpGBKStr,gbkLen,NULL,NULL); //获取转换到Unicode编码后所需要的字符空间长度
logPrintf("222222222222\n");
//lpUnicodeStr = new WCHAR[nRetLen + 1]; //为Unicode字符串空间
lpUnicodeStr = (WCHAR*)malloc( sizeof(WCHAR)*(nRetLen + 1));
logPrintf("333333333333\n");
nRetLen = MultiByteToWideChar(CP_ACP,0,(char *)lpGBKStr,gbkLen,lpUnicodeStr,nRetLen); //转换到Unicode编码
logPrintf("444444444444\n");
if(!nRetLen) //转换失败则出错退出
return 0;
logPrintf("555555555555\n");
nRetLen = WideCharToMultiByte(CP_UTF8,0,lpUnicodeStr,nRetLen,NULL,0,NULL,NULL); //获取转换到UTF8编码后所需要的字符空间长度
logPrintf("66666666666\n");
if(!lpUTF8Str) //输出缓冲区为空则返回转换后需要的空间大小
{
logPrintf("77777777777\n");
if(lpUnicodeStr)
free(lpUnicodeStr);
logPrintf("88888888888\n");
return nRetLen;
}
if(nUTF8StrLen < nRetLen) //如果输出缓冲区长度不够则退出
{
logPrintf("999999999999\n");
if(lpUnicodeStr)
free(lpUnicodeStr);
logPrintf("@@@@@@@@@@@@\n");
return 0;
}
logPrintf("#############\n");
nRetLen = WideCharToMultiByte(CP_UTF8,0,lpUnicodeStr,nRetLen,(char *)lpUTF8Str,nUTF8StrLen,NULL,NULL); //转换到UTF8编码
logPrintf("$$$$$$$$$$$$$\n");
if(lpUnicodeStr)
free(lpUnicodeStr);
logPrintf("%%%%%%%%%%%%%\n");
return nRetLen;
}
int UTF8ToGBK(unsigned char * lpUTF8Str,unsigned char * lpGBKStr,int nGBKStrLen)
{
wchar_t * lpUnicodeStr = NULL;
int nRetLen = 0;
if(!lpUTF8Str) //如果UTF8字符串为NULL则出错退出
return 0;
nRetLen = MultiByteToWideChar(CP_UTF8,0,(char *)lpUTF8Str,-1,NULL,NULL); //获取转换到Unicode编码后所需要的字符空间长度
//lpUnicodeStr = new WCHAR[nRetLen + 1]; //为Unicode字符串空间
lpUnicodeStr = (WCHAR*)malloc( sizeof(WCHAR)*(nRetLen + 1));
nRetLen = MultiByteToWideChar(CP_UTF8,0,(char *)lpUTF8Str,-1,lpUnicodeStr,nRetLen); //转换到Unicode编码
if(!nRetLen) //转换失败则出错退出
return 0;
nRetLen = WideCharToMultiByte(CP_ACP,0,lpUnicodeStr,-1,NULL,NULL,NULL,NULL); //获取转换到GBK编码后所需要的字符空间长度
if(!lpGBKStr) //输出缓冲区为空则返回转换后需要的空间大小
{
if(lpUnicodeStr)
free(lpUnicodeStr);
return nRetLen;
}
if(nGBKStrLen < nRetLen) //如果输出缓冲区长度不够则退出
{
if(lpUnicodeStr)
free(lpUnicodeStr);
return 0;
}
nRetLen = WideCharToMultiByte(CP_ACP,0,lpUnicodeStr,-1,(char *)lpGBKStr,nRetLen,NULL,NULL); //转换到GBK编码
if(lpUnicodeStr)
free(lpUnicodeStr);
return nRetLen;
}
int _stdcall fmSendAndWaitRecJsonData(char * _inJson, char * _outJson)
{
int length, siz;
int isgbk = 1;
char in[MAX_BUF_SIZE] = {0};
memset(g_clientInfo.sendBuf, 0, MAX_BUF_SIZE);
memset(g_clientInfo.recvBuf, 0, MAX_BUF_SIZE);
memset(g_clientInfo.tempBuf, 0, MAX_BUF_SIZE);
memset(g_clientInfo.tmpBuf, 0, MAX_BUF_SIZE);
logPrintf("INJSON:%s\r\n", _inJson);
strcpy(in, _inJson);
if(isgbk == 1)
{
length = GBKToUTF8(in, strlen(in), g_clientInfo.sendBuf, MAX_BUF_SIZE - 100);
g_clientInfo.sendBuf[length] = 0;
logPrintf("gbk to utf-8:%s\r\n", g_clientInfo.sendBuf);
}else
{
strcpy(g_clientInfo.sendBuf, _inJson);
}
if(0 != try2Connect2Clinent() )
{
logPrintf("try2Connect2Clinent failed !\n");
closesocket(g_clientInfo.sock);
g_clientInfo.sock = 0;
return 101;
}
if( 0 != addCheckValueAndSendData2Sock() )
{
logPrintf("addCheckValueAndSendData2Sock failed !\n");
closesocket(g_clientInfo.sock);
g_clientInfo.sock = 0;
return 102;
}
if(0 != recvAndCheckDataFromSock() )
{
logPrintf("recvAndCheckDataFromSock failed !\n");
closesocket(g_clientInfo.sock);
g_clientInfo.sock = 0;
return 103;
}
if (isgbk == 1)
{
siz = UTF8ToGBK(g_clientInfo.tempBuf, g_clientInfo.tmpBuf, MAX_BUF_SIZE - 100);
logPrintf("utf-8 to gbk:%s\r\n", g_clientInfo.tmpBuf);
strcpy_s(_outJson, siz, g_clientInfo.tmpBuf);
_outJson[siz] = '\0';
}
else
strcpy(_outJson, g_clientInfo.tmpBuf);
closesocket(g_clientInfo.sock);
g_clientInfo.sock = 0;
return 0;
}
LIBRARY
EXPORTS
initFmDll
fmSendAndWaitRecJsonData
endFmDll
\ No newline at end of file
#ifndef FMNETWORK_H
#define FMNETWORK_H
/*************************************************
*功能:初始化dll(调用一次)
*返回:-1 失败;0 成功;
**************************************************/
int _stdcall initFmDll();
/*************************************************
*
*功能:发送和接收数据(调用该方法会阻塞直到接收到数据或超时[内部超时时间为60秒,从该方法被调用时计算])
*
*参数:_inJson输入参数(传入参数必须为合法的json字符串,且长度小于8192,传入参数汉字编码需韦UTF-8)
* _outJson输出参数(空的字符数组,数组长度需大于4096)
*
*返回:0 成功;
* 101 socket连接fmclient.exe失败
* 102 发送的数据不合法或发送数据到fmclient.exe失败
* 103 接收fmclient.exe数据失败
**************************************************/
int _stdcall fmSendAndWaitRecJsonData(const char * _inJson, char * _outJson);
/*************************************************
*
*功能:清理dll(卸载fmsocket.dll调用一次)
**************************************************/
void _stdcall endFmDll();
#endif
\ No newline at end of file
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <direct.h>
#include <io.h>
#include <time.h>
#include <windows.h>
#include <winsock.h>
#include <DbgHelp.h>
#include "..\fmdll\fmnetwork.h"
#define MAX_BUF_SIZE 4096
#pragma comment(lib, "..\\Debug\\fmdll.lib")
void GetProcPath(char * pathBuf)
{
int curPos;
GetModuleFileName(NULL, pathBuf, MAX_PATH);
curPos = strlen(pathBuf) - 1;
while('\\' != pathBuf[curPos])
{
curPos--;
}
curPos++;
pathBuf[curPos] = '\0';
}
int main()
{
FILE *fp = NULL;
char in[MAX_BUF_SIZE] = {0};
char out[MAX_BUF_SIZE] = {0};
fp = fopen("F:\\VM\\fm\\fmdlllog\\ld.log", "r");
fscanf(fp, "%s", in);
printf("1: %s\r\n", in );
if(0 != initFmDll())
{
printf("sendData2Client failed !\n");
return 0;
}
if(0 != fmSendAndWaitRecJsonData(in, out))
{
printf("fmSendAndWaitRecJsonData failed !\n");
}
printf("recive data : %s \n", out);
Sleep(2*1000);
endFmDll();
return 0;
}
//int main()
//{
// char _inJson[MAX_BUF_SIZE] = "{\"ver\":2,\"business_date\":\"20170928\",\"transactions\":[{\"vdata\":\"2017-09-29\",\"code\":\"992441740\",\"pay_amount\":3250,\"products\":[{\"pid\":\"0802761\",\"sales_type\":\"Normal\",\"consume_num\":\"1\",\"name\":\"L焗烤三文治#\",\"price\":\"000000000650\",\"pcata\":\"081312\"},{\"pid\":\"1300985\",\"sales_type\":\"Normal\",\"consume_num\":\"1\",\"name\":\"农夫山庄经典九制妙酸奶梅\",\"price\":\"000000000600\",\"pcata\":\"130401\"},{\"pid\":\"0201681\",\"sales_type\":\"Normal\",\"consume_num\":\"1\",\"name\":\"D吉香居麻辣大头菜\",\"price\":\"000000000300\",\"pcata\":\"020801\"},{\"pid\":\"1301832\",\"sales_type\":\"Normal\",\"consume_num\":\"1\",\"name\":\"洽洽焦糖味瓜子\",\"price\":\"000000000700\",\"pcata\":\"130201\"},{\"pid\":\"0700746\",\"sales_type\":\"Normal\",\"consume_num\":\"1\",\"name\":\"农夫水溶C100西柚#\",\"price\":\"000000000500\",\"pcata\":\"070403\"},{\"pid\":\"0802764\",\"sales_type\":\"Normal\",\"consume_num\":\"2\",\"name\":\"L榴莲酥#\",\"price\":\"000000000250\",\"pcata\":\"081312\"}],\"ebcode\":\"0000000256\"}],\"reqtype\":71,\"store_id\":\"2612\",\"operator_id\":\"01\",\"station_id\":\"2612\",\"trans_id\":\"2017092826121187\"}";
// //char _inJson[MAX_BUF_SIZE] ="{\"ver\":2, \"operator_id\": \"00000002\", \"reqtype\": 72,\"station_id\": 1,\"store_id\": \"999999\",\"trans_id\": 110,\"business_date\":\"20150701\",\"transactions\": [{\"amount\": 0.01,\"undis_amount\":0,\"code\": \"28\"}]}";
// //char _inJson[MAX_BUF_SIZE] = "{\"ver\":2,\"operator_id\": \"00000002\", \"reqtype\": 72,\"station_id\": 1,\"store_id\": \"999999\",\"trans_id\": 110,\"business_date\":\"20150701\",\"transactions\": [{\"amount\: 1974,\"undis_amount\":0,\"code\": \"289631206996295092\",\"products\: [{\"consume_num\": 1,\"sales_type\": \"FREE\",\"price\": 1000,\"pid\": \"0079020\", \"seq\": 1 },{ \"consume_num\": 1,\"sales_type\": \"NORMAL\",\"price\": 1974,\"pid\": \"0077842\",\"seq\": 2}]}]}";
// //char _inJson[MAX_BUF_SIZE] = "{\"ver\":1,\"reqtype\": 0,\"coupon\": \"122222222222\",\"station_id\": \"1\",\"store_id\": \"999999\",\"operator_id\": \"00000002\" }";
// //char _inJson[MAX_BUF_SIZE] = "{\"business_date\":\"20170216\",\"clientReqCount\":1,\"operator_id\":\"00000002\",\"reqtype\":72,\"station_id\":1,\"store_id\":\"99999\",\"trans_id\":1,\"transactions\":[{\"amount\":1,\"code\":\"130172197545004263\"}],\"ver\":1}";
// char _outJson[MAX_BUF_SIZE] = {0};
// char path[MAX_PATH] = {0};
// int i = 0;
//
//
//
// GetProcPath(path);
// printf("%s", path);
//
// if(0 != initFmDll())
// {
// printf("sendData2Client failed !\n");
// goto MainExit;
// }
//
// do
// {
// if(0 != fmSendAndWaitRecJsonData(_inJson, _outJson))
// {
// printf("fmSendAndWaitRecJsonData failed !\n");
// }
// printf("recive data : %s \n", _outJson);
// Sleep(2*1000);
// i ++;
// }while(i < 2);
// endFmDll();
//MainExit:
// system("pause");
// return 0;
//}
//#include <stdio.h>
//#include <stdlib.h>
//#include <Windows.h>
//
//typedef int ( *Init ) ();
//typedef void ( *Destory ) ();
//typedef int ( *SendAndReceiveData ) (const char *, char *);
//
//int main(int argc, char **argv)
//{
//
// HINSTANCE _socket_hd;
// Init _init;
// Destory _destory;
// SendAndReceiveData _sendandreceivedata;
//
// char _senddata [8000] = "{\"coupon\":\"123456789\",\"operator_id\":\"02\",\"reqtype\":0,\"station_id\":1,\"store_id\":\"2\",\"ver\":2}";
// char _receivedata[8000] = {0};
//
// /***********************************************************************
// *加载FMSocket.dll
// ************************************************************************/
// _socket_hd = LoadLibraryA( "FMSocket.dll" );
// if(_socket_hd == NULL )
// {
// printf( "load FMSocket.dll failed \n" );
// return -1;
// }
//
// /***********************************************************************
// *获取FMSocket.dll数据发送初始化方法
// ************************************************************************/
// _init = ( Init )GetProcAddress( _socket_hd, "Init" );
// if(_init == NULL)
// {
// printf( "get function init failed \n" );
// return -1;
// }
//
// /***********************************************************************
// *获取FMSocket.dll数据发送销毁方法
// ************************************************************************/
// _destory = ( Destory )GetProcAddress( _socket_hd, "Destory" );
// if( _destory == NULL )
// {
// printf( "get function Destroy failed \n" );
// return -1;
// }
//
// /***********************************************************************
// *获取FMSocket.dll数据接收和发送方法
// ************************************************************************/
// _sendandreceivedata = ( SendAndReceiveData )GetProcAddress( _socket_hd,"SendAndReceiveData" );
// if( _sendandreceivedata == NULL )
// {
// printf( "get function SendAndReceiveData failed \n" );
// return -1;
// }
//
// /***********************************************************************
// *初始化
// ************************************************************************/
// if( _init() == -1 )
// {
// printf( "init FMSocket.dll failed \n" );
// return -1;
// }
// /***********************************************************************
// *发送和接收数据
// ************************************************************************/
// if( _sendandreceivedata(_senddata, _receivedata) == 0 )
// {
// printf( "receive data from fmclient : %s \n", _receivedata );
// }else
// {
// printf( "receive data from fmclient failed \n" );
// }
// /***********************************************************************
// *清理
// ************************************************************************/
// _destory();
//
// FreeLibrary(_socket_hd);
//
// system( "pause" );
//
// return 0;
//}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment