B.7 the csample_view class, The csample_view class – Schneider Optics Web Embedded Server User Manual
Page 79

Ethernet Developers Guide
840 USE 115 00 Version 1.0
69
B.7
The CSample_View Class
The CSample_View class manages the TCP/IP connection, sends requests to
remote nodes, and displays either connection state, or the results of a transaction.
In addition it sets the states of the tool bar buttons and menu items.
B.7.1
Accessing TCP/IP
The CSample_View interfaces with window sockets via its application
programming interface, and via messages sent by the window sockets DLL to the
CSample_View window. The reference for the window socket API is given above.
The first call made to the window sockets DLL must be WSAStartup. This call is
made by InitInstance member function of the CSample_app class. The last call to
the window socket DLL must be WSACleanup. This call is made by the
ExitInstance member function of the Csample_app class.
The CSample_View allocates and sets the socket attributes. The attributes it sets
are given in the following table.
z
Set Linger to cause a hard close
z
Receive out of band data in the normal data stream
z
Disable Nagel algorithm for send coalescing
When Nagel algorithm is disabled, if the stack receives an application message, it
will immediately pass the message to the application and will send a TCP/IP
acknowledgment message. Although this can generate more traffic, the application
receives the message sooner then if Nagel algorithm is enabled. The member
function tcpip_setsocket_options sets the socket attributes.
The window socket interface provides the WSAAsyncSelect function which notifies
the window of network events. The member function tcpip_setsocket_options calls
WSAAsyncSelect function. The different events are given by the following table.
Event
Description
FD_READ
A socket can read data
FD_WRITE
A socket can write data
FD_OOB
A socket can read out of band data
FD_CONNECT
A connect response has been received
FD_CLOSE
The connection has been closed