User guide
Ethernet Developers Guide
70  
840 USE 115 00 Version 1.0
One of the parameters to the WSAAs
y
ncSelect is a user defined messa
g
e the 
window socket DLL sends to the window.  The sample application user messa
g
e is 
WM_TCPIP_EVENT and is defined in the file wn_msh.h. MFC architectural 
framework calls the CSample_View tcpip_event member function to process this 
messa
g
e. Like all functions which process messa
g
es, tcpip_event parameters are 
a word and a lon
g
 word.  The word parameter is the socket, and the lon
g
 word 
parameter contains the network event , and an error code. Tcpip_event examines 
the network event and calls the member function indicated in the followin
g
 table. 
B.7.2 Application Message Format 
TCP/IP transmits a messa
g
e as a stream. There is no indication of the start of a 
messa
g
e nor the end of the messa
g
e. The NOE option module adds a header to 
determine the messa
g
e boundaries. The messa
g
e is a Modbus messa
g
e. The 
header contains the followin
g
 fields. 
Invoke Identifier. This two b
y
te field associates a re
q
uest with the response. 
The client application picks the invoke identifier, and server returns the same 
invoke identifier in the response. 
Protocol T
y
pe. This two b
y
te field identifies the protocol t
y
pe. Currentl
y
, the 
onl
y
 protocol supported is Modbus. 
Command Len
g
th. This two b
y
te field is the size of the rest of the messa
g
e. 
Destination Identifier. This one b
y
te field is reserved for future use.
The Modbus messa
g
e follows the header. The messa
g
e does not contain the 
address field, instead, the first b
y
te is the Modbus function code.
The data structure for the header is declared in modbus.h and the CSample_View 
encode_header function encodes the header. The member functions 
encode_clear_stats, encode_read_stats, encode_read_r
q
, and encode_write_r
q
encode the correspondin
g
 Modbus messa
g
es. 
Network Event Member Function
FD_READ OnTcpIpRead()
FD_WRITE OnTcpIpWrite()
FD_OOB OnTcpIpOob()
FD_CONNECT ⁄ OnTcpIpConnect
FD_CLOSE OnTcpIpClose()










