Udp (When Using Extended Memobus Protocol - YASKAWA MP920 User Manual

Machine controller
Table of Contents

Advertisement

C.2.2

UDP (When Using Extended MEMOBUS Protocol)

< Configuration and Setting Example >
MP920 (Master)
PORT
CN1
IP address: Depends on the Slave (remote) setting.
Port number: Depends on the Slave (remote) setting.
#include <stdio.h>
#include <winsock.h>
#include <winioctl.h>
int
sd;
struct sockaddr_in my;
struct sockaddr_in from;// Work to store the remote IP address and port number
char
sbuf[2048];
char
rbuf[2048];
#define MY_IP
0xC0A8010A // Local IP address: 192.168.1.10
#define MY_PORT
8000
// 218TCPSrv.C
extern void mk_rsp_data(int*);
extern int chk_cmd_data(int);
void main_udp_Srv(void);
void main_udp_Srv(void)
{
WSADATAwsadata;
int rc, slen, rlen, send_len, fromlen;
// Declaration to use Winsock.dll (always required at first.)
rc = WSAStartup( 0x0101, &wsadata );
if ( rc != 0 )
{
exit(0);
}
// Clears the sockaddr structure (IP address, port number, etc.) to zero.
memset( (char *)&my, 0, sizeof(struct sockaddr));
memset( (char *)&from, 0, sizeof(struct sockaddr));
// Declaration of local IP address and port number
my.sin_family = AF_INET;
my.sin_addr.s_addr = htonl( MY_IP );
my.sin_port = htons( MY_PORT );
Ethernet
// Socket
// Work to store local IP address and port number
// Send buffer
// Receive buffer
// Local port number: 8000
C-15
C.2 Sample Programs for Slave Station
Personal computer (Slave)
IP address: 192. 168. 1. 10.
Port number: 8000
C

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents