|
The server is VB, use socket control
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
Client C ++
#define MaxRecv 1024
SOCKET serverSocket;
serverSocket = NULL;
sockaddr_in m_addr;
The
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);
} |
|