Mitsubishi Electric QJ71E71-100 User Manual page 407

Q corresponding ethernet interface module
Table of Contents

Advertisement

// Perform receiving size check and receiving processing simultaneously
rbuf_idx = 0;
recv_size = 0;
while(1) {
length = recv(socketno, (char*)(&r_buf[rbuf_idx]), (BUF_SIZE - rbuf_idx), 0);
if(length == 0) {
Sockerror(ERROR_RECEIVE);
return (SOCK_NG);
}
if(length == SOCKET_ERROR) {
nErrorStatus = WSAGetLastError();
if(nErrorStatus != WSAEWOULDBLOCK) {
Sockerror(ERROR_RECEIVE);
return (SOCK_NG);
} else {
continue;
}
} else {
rbuf_idx += length;
recv_size += length;
if(recv_size >= RECV_ANS_2)
break;
}
}
r_buf[rbuf_idx] = '\0' ;
printf("\receive data\n%s\n", r_buf);
if(shutdown(socketno,2)!=SOCK_OK){
Sockerror(ERROR_SHUTDOWN);
return(SOCK_NG);
}
if(closesocket(socketno)!=SOCK_OK){
Sockerror(ERROR_CLOSE);
return(SOCK_NG);
}
Closeflag=FLAG_OFF;
WSACleanup();
(To the next page)
// Receive data storage head index
// initialization
// Initialize the number of receive data
// Response data receiving
// Is connection cut off?
// Error handling
// Error handling
// Repeat until messages are received
// Update the receive data storage
// position
// Update the number of receive data
// Have all response messages been
// received?
// Stop repeating as messages have
// been received
// Set NULL at the end of receive data
// Processing to disable
// sending/receiving
// Error handling
// Close processing
// Error handling
// Connection completion flag off
// Release Winsock.DLL
APPENDICES
A
405

Advertisement

Table of Contents
loading

This manual is also suitable for:

Qj71e71-b5Qj71e71-b2

Table of Contents