EasyManua.ls Logo

Mitsubishi Electric MELSEC-L Series - Page 358

Mitsubishi Electric MELSEC-L Series
382 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
356
int nErrorStatus; // Error information storage variable
int Dmykeyin; // Dummy key input
int Closeflag; // Connection completion flag
int socketno;
int main()
{
WORD wVersionRequested=MAKEWORD(1,1); // Winsock Ver 1.1 request
WSADATA wsaData;
int length; // Communication data length
unsigned char s_buf[BUF_SIZE]; // Send buffer
unsigned char r_buf[BUF_SIZE]; // Receive buffer
int rbuf_idx; // Receive data storage head index
int recv_size; // Number of receive data
struct sck_inf sc;
struct sockaddr_in hostdata; // External device side data
struct sockaddr_in aj71e71; // E71 side data
void Sockerror(int); // Error handling function
unsigned long ulCmdArg ; // Non-blocking mode setting flag
sc.my_addr.s_addr=htonl(INADDR_ANY); // External device side IP address
sc.my_port=htons(0); // External device side port number
sc.aj_addr.s_addr=inet_addr("192.0.1.253"); // E71 side IP address (C00001FDH)
sc.aj_port=htons(0x2000); // E71 side port number
Closeflag=FLAG_OFF; // Connection completion flag off
nErrorStatus=WSAStartup(wVersionRequested,&wsaData); // Winsock Initial processing
if(nErrorStatus!=SOCK_OK) {
Sockerror(ERROR_INITIAL); // Error handling
return(SOCK_NG);
}
printf("Winsock Version is %ld.%ld\n",HIBYTE(wsaData.wVersion), LOBYTE(wsaData.wVersion));
printf("AJ_test Start\n");
socketno=socket(AF_INET,SOCK_STREAM,0); // Create socket for TCP/IP
if(socketno==INVALID_SOCKET){
Sockerror(ERROR_SOCKET); // Error handling
return(SOCK_NG);
}

Table of Contents

Other manuals for Mitsubishi Electric MELSEC-L Series

Related product manuals