您好,登錄后才能下訂單哦!
#include<windows.h>
#include<iostream>
//客戶端初始化 獲取handle上下
typedef int(*CltSocketInit)(void **handle);
//客戶端發(fā)報文
typedef int(*CltSocketSend)(void *handle, unsigned char *buf, int buflen);
//客戶端收報文
typedef int(*CltSocketRev)(void *handle, unsigned char *buf, int *buflen);
//客戶端釋放資源
typedef int(*CltSocketDestory)(void *handle);//以上都是指針函數(shù)
int main(){
HINSTANCE hinstance = NULL;
hinstance = ::LoadLibrary("D:\\SocketClient.dll");//獲得句柄
CltSocketInit cltSocketInit = (CltSocketInit)GetProcAddress(hinstance, "cltSocketInit");//獲取函數(shù)地址傳給函數(shù)指針!
CltSocketSend cltSocketSend = (CltSocketSend)GetProcAddress(hinstance, "cltSocketSend");
CltSocketRev cltSocketRev = (CltSocketRev)::GetProcAddress(hinstance, "cltSocketRev");
CltSocketDestory cltSocketDestory = (CltSocketDestory)::GetProcAddress(hinstance, "cltSocketDestory");
void *handle = NULL;
unsigned char buf[100];
int buflen = 10;
memcpy(buf, "ddddddddddssssssssss", 10);
unsigned char out[100] = { 0 };
int outlen = 0;
int ret = cltSocketInit(&handle);
ret = cltSocketSend(handle, buf, buflen);
ret = cltSocketRev(handle, out, &outlen);
ret = cltSocketDestory(handle);
printf("out:%s", out);
system("pause");
}
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內(nèi)容。