|
楼主 |
发表于 2020-4-16 21:30:02
|
显示全部楼层
服务端是VB,使用socket控件
Dim r1(1023) As Byte
Dim r2(1023) As Byte
Dim r3(487) As Byte
m_DeviceSocket.SendData r1
m_DeviceSocket.SendData r2
m_DeviceSocket.SendData r3
客户端c++
#define MaxRecv 1024
SOCKET serverSocket;
serverSocket = NULL;
sockaddr_in m_addr;
WORD version = MAKEWORD(2,0);
WSADATA wsadata;
WSAStartup(version,&wsadata);
serverSocket = socket(AF_INET,SOCK_STREAM,0);
m_addr.sin_family = AF_INET;
m_addr.sin_addr.S_un.S_addr = inet_addr((char*)"192.168.1.243");
m_addr.sin_port = htons(12343);
connect(serverSocket,(LPSOCKADDR)&m_addr,sizeof(m_addr));
CHAR recvStr[MaxRecv];
long reclen = 0;
while (1) {
memset(recvStr,0,sizeof(recvStr));
reclen = recv(serverSocket,recvStr,sizeof(recvStr),0);
}
|
|