EasyManua.ls Logo

YASKAWA MP920 - UDP (When Using Extended MEMOBUS Protocol

YASKAWA MP920
336 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...
C.2 Sample Programs for Slave Station
C-15
C
C.2.2 UDP (When Using Extended MEMOBUS Protocol)
#include <stdio.h>
#include <winsock.h>
#include <winioctl.h>
int sd;
// Socket
struct sockaddr_in my;
// Work to store local IP address and port number
struct sockaddr_in from;
// Work to store the remote IP address and port number
char sbuf[2048];
// Send buffer
char rbuf[2048];
// Receive buffer
#define MY_IP 0xC0A8010A
// Local IP address: 192.168.1.10
#define MY_PORT 8000
// Local port number: 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
CN1
PORT
MP920 (Master)
Personal computer (Slave)
IP address: Depends on the Slave (remote) setting.
Port number: Depends on the Slave (remote) setting.
IP address: 192. 168. 1. 10.
Port number: 8000
Configuration and Setting Example

Table of Contents

Related product manuals