Mitsubishi Electric QJ71E71-100 User Manual page 417

Q corresponding ethernet interface module
Table of Contents

Advertisement

WSACleanup();
printf("\nQJ_test End. \n\nNormally completed. \n");
printf("Program is closed. Press any key. \n");
Dmykeyin = getchar();
return (SOCK_OK);
}
BOOL DataRecv(int socketno, unsigned char *pR_buf, int size_max) // Receive processing function
{
int length;
int rbuf_idx;
int recv_size;
// Performs receive processing while simultaneously making size check
rbuf_idx = 0;
recv_size = 0;
while(1) {
length = recv(socketno, ((char*)(pR_buf + rbuf_idx)), (BUF_SIZE - rbuf_idx), 0);
if(length == 0) {
return (FALSE);
}
if(length == SOCKET_ERROR) {
nErrorStatus = WSAGetLastError();
if(nErrorStatus != WSAEWOULDBLOCK) {
return (FALSE);
} else {
continue;
}
} else {
rbuf_idx += length;
recv_size += length;
if(recv_size >= size_max)
break;
}
}
*(pR_buf + rbuf_idx) = '\0' ;
return (TRUE);
}
(To the next page)
// Winsock.DLL release
// Waiting for key input
// Communication data length
// Receive data storage starting index
// Number of received data
// Receive data storage starting index initialization
// Initializes the number of received data
// Response data receive
// Has connection been cut?
// Error handling
// Error handling
// Repeated until data are received
// Updates receive data storage position
// Updates the number of received data
// Have all response messages received?
// Stops repeating as data are received
// At the end of received data
// set NULL
// Normal termination
APPENDICES
A
415

Advertisement

Table of Contents
loading

This manual is also suitable for:

Qj71e71-b5Qj71e71-b2

Table of Contents