Mitsubishi MELSEC-F User Manual page 280

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

Advertisement

APPENDIX
int main()
{
WORD wVersionRequested=MAKEWORD(1,1);
WSADATA wsaData;
int length;
unsigned char s_buf[BUF_SIZE];
unsigned char r_buf[BUF_SIZE];
int rbuf_idx;
int recv_size;
struct sck_inf sc;
struct sockaddr_in hostdata;
struct sockaddr_in FX3UENET;
void Sockerror(int);
unsigned long ulCmdArg ;
sc.my_addr.s_addr=htonl(INADDR_ANY);
sc.my_port=htons(0);
sc.FX_IP_addr.s_addr=inet_addr("172.16.56.99"); // Ethernet block side IP address
(AC103863h)
sc.FX_port=htons(10000);
Closeflag=FLAG_OFF;
nErrorStatus=WSAStartup(wVersionRequested,&wsaData); // Winsock Initial processing
if (nErrorStatus!=SOCK_OK) {
Sockerror(ERROR_INITIAL);
return (SOCK_NG);
}
printf ("Winsock Version is %ld.%ld\n",HIBYTE(wsaData.wVersion),LOBYTE(wsaData.wVersion));
printf ("FX3U-ENET Test Start\n");
socketno=socket(AF_INET,SOCK_STREAM,0);
if (socketno==INVALID_SOCKET){
Sockerror (ERROR_SOCKET);
return(SOCK_NG);
}
hostdata.sin_family=AF_INET;
hostdata.sin_port=sc.my_port;
hostdata.sin_addr.s_addr=sc.my_addr.s_addr;
if(bind(socketno,(LPSOCKADDR)&hostdata,sizeof(hostdata))!=SOCK_OK){
Sockerror(ERROR_BIND);
return(SOCK_NG);
}
FX3UENET.sin_family=AF_INET;
FX3UENET.sin_port=sc.FX_port;
FX3UENET.sin_addr.s_addr=sc.FX_IP_addr.s_addr;
if(connect(socketno,(LPSOCKADDR)&FX3UENET,sizeof(FX3UENET))!=SOCK_OK){
Sockerror(ERROR_CONNECT);
return(SOCK_NG);
}
App - 10
// Winsock Ver 1.1 request
// Communication data length
// Send buffer
// Receive buffer
// Receive data storage head index
// Number of receive data
// External device side data
// Ethernet block side data
// Error handling function
// Non-blocking mode setting flag
// External device side IP address
// External device side port number
// Ethernet block side port number
// Connection completion flag off
// Error handling
// Create socket for TCP/IP
// Error handling
// Bind
// Error handling
// Connection (Active open)
// Error handling
MELSEC-F
App - 10

Advertisement

Table of Contents
loading

This manual is also suitable for:

Fx3u-enetFx3uc-enet

Table of Contents