Mitsubishi MELSEC-F User Manual page 282

Hide thumbs Also See for MELSEC-F:
Table of Contents

Advertisement

APPENDIX
while(1) {
length = recv(socketno, &r_buf[rbuf_idx], (BUF_SIZE - rbuf_idx), 0);
if(length == 0) {
Sockerror(ERROR_RECIEVE);
return (SOCK_NG);
}
if(length == SOCKET_ERROR) {
nErrorStatus = WSAGetLastError();
if(nErrorStatus != WSAEWOULDBLOCK) {
Sockerror(ERROR_RECIEVE);
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();
printf("\nFX3U-ENET Test End.\n\n Normally completed. \n");
printf("Press any key to exit the program.\n");
Dmykeyin=getchar();
return(SOCK_OK);
}
void Sockerror(int error_kind)
{
if(error_kind==ERROR_INITIAL){
printf("Initial processing is abnormal.");
}
else{
nErrorStatus=WSAGetLastError();
switch(error_kind){
case ERROR_SOCKET:
App - 12
printf("Failed to create socket.");
break;
MELSEC-F
// 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
// Wait for key input
// Error handling function
App - 12

Advertisement

Table of Contents
loading

This manual is also suitable for:

Fx3u-enetFx3uc-enet

Table of Contents