Ethernet Developers Guide

If the remote node is an IP address, or if it’s a name that has been resolved, then CSample_View tcpip_connect_rq function is called to initiate a connect request to the remote node. The listen port for the connect request is five hundred and two, and is defined by the constant MBAP_LISTEN_PORT in modbus.h. If tcpip_connect_rq succeeded in initiating a connect request, then tcpip_connect_rq changes the transmit state to CONNECTING, otherwise it changes the transmit state to IDLE.

The window sockets DLL generates a FD_CONNECT event which indicates if the connect request succeeded or failed. CSample_View OnTcpIpConnect function processes the FD_CONNECT event. If the connect request succeeded, OnTcpIpConnect changes the transmit state to CONNECTED, otherwise it changes the state to IDLE.

Recall that MFC architectural framework calls CSample_View OnPollInterval member function to processes WM_POLL_INTERVAL message sent as result of CMainFrame class processing a WM_TIMER message. OnPollInterval examines the transmit state. If the transmit state is CONNECTED, and the user has selected a transaction type, then OnPollInterval calls CSample_View TransmitUserRequest function.

TransmitUserRequest encodes a request based on the transaction type, saves the current time, and calls CSample_View TransmitMessage function. OnPollInterval uses the saved time to determine when to transmit the next request.

TransmitMessage attempts to send a message to the remote side. To send the message, TransmitMessage enters a loop. In the body of the loop transmit message calls the window socket DLL send function. The following lists the outcomes of the send function and the actions taken.

The message was sent successfully. TransmitMessage changes the transmit state to TX_DONE and exits the loop.

Only part of the message was sent. TransmitMessage reenters the loop.

Send function returns an error indicating there is no buffer space within the transport system. TransmitMessage changes the transmit state to BLOCKED

zand exists the loop.

Send function returns some other error. TransmitMessage closes the connection, changes the transmit state to IDLE, and exits the loop.

When buffer space within the transport system becomes available to transmit messages, the window socket DLL generates a FD_WRITE event. CSample_View OnTcpWrite function processes the FD_WRITE function by calling TransmitMessage.

840 USE 115 00 Version 1.0

73

Page 83
Image 83
Schneider Optics Modicon Quantum Ethernet manual Exists the loop