App - 8
MELSEC-F
APPENDIX
App - 8
(4) Program on the external device side
The program example of the external device shown below accesses the FX
3U
of
the station in which the Ethernet module is installed.
When this program is executed, the contents of the following communication
messages are displayed in sequence:
1) Batch write command message in word units
2) Batch write response message in word units
3) Batch read command message in word units
4) Batch read response message in word units
(1) The following explains an outline of the compiling procedure for a program
created using Microsoft Corporation Visual C
++
.NET
1) Start Visual C
++
.
2) Prepare for program creation.
Select "New Project" from the project tab, select "Win32 console project",
and create an empty project with the name "ENETSAMP".
3) Add ENETSAMP.C to the project and create a program.
(See the program example on the next page.)
4) Compile the created file from the compile screen of the build menu.
5) From the project menu property setting screen, add WSOCK32.LIB to the
linker addition dependency files.
6) Create an executable file (ENETSAMP.EXE) on the build screen of the build
menu.
7) End Visual C
++
.NET.
8) Execute ENETSAMP.EXE.
(2) Outline of the procedure for calling the socket routine
REMARK
Start
socket()
bind()
Passive open
Active open
UDP
listen()
connect()
accept()
send()/recv()
sendto()/recvfrom()
shutdown()
closesocket
Complete
(Create socket)
(Bind)
(Open)
(Communicate)
(Disable sending/receiving)
(Close)