Appendix C C Language Sample Programs; Sample Programs For Master Station; Tcp (When Using Extended Memobus Protocol (Sfc = 09 - YASKAWA MP920 User Manual

Machine controller
Table of Contents

Advertisement

Appendix C C Language Sample Programs

C.1.1 TCP (When Using Extended MEMOBUS Protocol (SFC = 09))
C.1

Sample Programs for Master Station

C.1.1

TCP (When Using Extended MEMOBUS Protocol (SFC = 09))

< Configuration and Setting Example >
#include <stdio.h>
#include <winsock.h>
#include <winioctl.h>
int sd;
struct sockaddr_in my;
struct sockaddr_in dst;
#define MY_IP
#define MY_PORT 5000
#define DST_IP
#define DST_PORT 5000
char sbuf[2048];
char rbuf[2048];
void main_tcp(void);
void mk_cmd_data(void);
int chk_rsp_data(int);
void main_tcp(void)
{
The programs listed in this appendix were prepared only for reference purpose and they may not
operate correctly in actual applications. To execute the programs, a socket library and C com-
piler must be installed on the personal computer.
The brief explanations on the program contents are written in italics after double-slash (//) in the
programs.
The line on the left end of the program indicates the positions of paragraph indentions.
MP920 (Slave)
PORT
CN1
IP address 192. 168. 1. 1
Port number 5000
/* Socket Discripter */
0xC0A80103 // Local IP address: 192.168.1.3
// Local port number
0xC0A80101 // Remote IP address: 192.168.1.1
// Remote port number
WSADATAwsadata;
int rc, slen, rlen;
// Declaration to use Winsock.dll (Always required at first.)
rc = WSAStartup( 0x0101, &wsadata );
if ( rc != 0 )
{
exit(0);
}
Personal computer (Master)
Ethernet
IP address 192. 168. 1. 3.
Port number 5000
C-2

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents