/**************************************************************************/
/** Sample program (program name: AJSAMP.CPP) **/
/** **/
/** This program is a sample program to conduct a **/
/** connection test between the E71 and target device. **/
/** This program accesses the data register (D) of **/
/** the PLC CPU installed together with the E71 **/
/** **/
/** Copyright(C) 2005 Mitsubishi Electric Corporation **/
/** All Rights Reserved **/
/**************************************************************************/
#include <stdio.h>
#include <winsock.h>
#define FLAG_OFF 0 // Completion flag OFF
#define FLAG_ON 1 // Completion flag ON
#define SOCK_OK 0 // Normal completion
#define SOCK_NG -1 // Abnormal completion
#define BUF_SIZE 4096 // Receive buffer size
#define ERROR_INITIAL 0 // Initial error
#define ERROR_SOCKET 1 // Socket creation error
#define ERROR_BIND 2 // Bind error
#define ERROR_CONNECT 3 // Connection error
#define ERROR_SEND 4 // Send error
#define ERROR_RECEIVE 5 // Receive error
#define ERROR_SHUTDOWN 6 // Shutdown error
#define ERROR_CLOSE 7 // Line close error
//Definitions for checking the receiving sizes
//#define RECV_ANS_1 4 // Receiving size of response message in reply to device write (1E frame)
#define RECV_ANS_1 22 // Receiving size of response message in reply to device write (3E frame)
//#define RECV_ANS_2 24 // Receiving size of response message in reply to device read (1E frame)
#define RECV_ANS_2 42 // Receiving size of response message in reply to device read (3E frame)
typedef struct sck_inf{
struct in_addr my_addr;
unsigned short my_port;
struct in_addr aj_addr;
unsigned short aj_port;
}sck_inf;