189 8069 5689

调用动态库!-创新互联

#include

10年积累的成都网站建设、成都网站制作经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先做网站设计后付款的网站建设流程,更有钦北免费网站建设让你可以放心的选择与我们合作。

#include

//客户端初始化 获取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");

}

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


网站栏目:调用动态库!-创新互联
网页路径:http://cdxtjz.cn/article/dgdepc.html

其他资讯