您好,登錄后才能下訂單哦!
#include<windows.h>
#include<iostream>
//客戶端初始化 獲取handle上下
typedef int(*CltSocketInit)(void **handle);
//客戶端發報文
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);//以上都是指針函數
int main(){
HINSTANCE hinstance = NULL;
hinstance = ::LoadLibrary("D:\\SocketClient.dll");//獲得句柄
CltSocketInit cltSocketInit = (CltSocketInit)GetProcAddress(hinstance, "cltSocketInit");//獲取函數地址傳給函數指針!
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");
}
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。