在C ++中使用VB.Net中的byte()的unsigned char * [英] unsigned char* in C++ with byte() in VB.Net
问题描述
大家好!
我通过LAN创建了一个模型服务器/客户端(TCP / IP,Socket)。
所以,服务器是由MFC应用程序开发的/>
客户端VB.Net
这是连接,等待,发送,重新安装和结束,没关系
所以,数据发送和重新安装是错误的。
在客户端,消息显示内存丢弃,数据发送正常但服务器没有读取它们。
我认为C ++中的变量unsigned char *是错误的(包类型)服务器)在VB.Net中使用
byte()(包类型客户端)
所以,我不知道,如何修复它。
可以帮我一个好的解决方案,想法。
非常感谢!
在VB中分配一个字节缓冲区让一个C ++填充字节。使用长度作为参数来避免缓冲区溢出。
i wolud写代码:
in vb .net
Dim 缓冲区( 200 )<跨度类= 代码关键字 >作为跨度> <跨度类= 代码关键字>字节跨度>
Call_C_Plus_Plus(缓冲液,<跨度类=code-digit> 200 )
in c ++
<预LANG = C ++> <跨度类= 代码关键字> INT 跨度> Call_C_Plus_Plus(<跨度类= 代码关键字>炭跨度> *缓冲液中。<跨度类=code-keyword> in len)
{
strncpy(buffer,my_c_message, 200 );
}
Hi all!
I have create a model server/client (TCP/IP, Socket) through LAN.
So, Server is developed by MFC application
Client by VB.Net
It's is connect, wait,send,revice and end , that's OK
so, data send and revice is error.
at client, message show memory is throw, data send OK but server not is read them.
I think it is error by variable unsigned char* in C++ (packet type server) with
byte() in VB.Net(packet type client)
So, i don't know, how to fix it.
Can help me a good solution, idea.
Thanks so much!
allocate a byte buffer in VB an let C++ fill the bytes. Use the length as parameter to avoid buffer overruns.
i wolud write code like that:
in vb.net
Dim buffer(200) as Byte Call_C_Plus_Plus(buffer,200)
in c++
int Call_C_Plus_Plus(char *buffer. in len) { strncpy( buffer, my_c_message, 200); }
这篇关于在C ++中使用VB.Net中的byte()的unsigned char *的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!