Winsock pdf
The rapid advances in performance and miniaturisation in microtechnology are constantly opening up new markets for the programmable logic controller PLC. Specially designed controller hardware or PC-based controllers, extended by hardware and software with real-time capability, now control highly complex automation processes.
This has been extended by the new subject of safe- related controllers, aimed at preventing injury by machines during the production process. The different types of PLC cover a wide task spectrum - ranging from small network node computers and distributed compact units right up to modular, fau- tolerant, high-performance PLCs. Socket type definitions in the Winsock2.
In Windows Sockets 1. The protocol to be used. The possible options for the protocol parameter are specific to the address family and socket type specified.
Possible values for the protocol are defined in the Winsock2. If a value of 0 is specified, the caller does not wish to specify a protocol and the service provider will choose the protocol to use.
The table below lists common values for the protocol although many other values are possible. If no error occurs, socket returns a descriptor referencing the new socket.
The socket function causes a socket descriptor and any related resources to be allocated and bound to a specific transport-service provider. Winsock will utilize the first available service provider that supports the requested combination of address family, socket type and protocol parameters. The socket that is created will have the overlapped attribute as a default. Sockets without the overlapped attribute can be created by using WSASocket.
When selecting a protocol and its supporting service provider this procedure will only choose a base protocol or a protocol chain, not a protocol layer by itself.
Unchained protocol layers are not considered to have partial matches on type or af either. A connection to another socket is created with a connect call. Once connected, data can be transferred using send and recv calls. When a session has been completed, a closesocket must be performed. The communications protocols used to implement a reliable, connection-oriented socket ensure that data is not lost or duplicated. Connectionless, message-oriented sockets allow sending and receiving of datagrams to and from arbitrary peers using sendto and recvfrom.
If such a socket is connected to a specific peer, datagrams can be sent to that peer using send and can be received only from this peer using recv. The IPv6 receive packet includes the packet payload and the next upper-level header. The IPv6 receive packet never includes the IPv6 packet header. On Windows XP and later, the following command can be used to list the Windows Sockets catalog to determine the service providers installed and the address family, socket type, and protocols that are supported.
The following is a step-by-step guide to getting started with Windows Sockets programming. It is designed to provide an understanding of basic Winsock functions and data structures, and how they work together. The client and server application that is used for illustration is a very basic client and server.
Several more advanced Winsock client and server samples are available on GitHub. They are listed below in order from higher to lower performance and are found in the following directories:. The programs include a Winsock server iocpserver that uses the WSAAccept function, a Winsock server iocpserverex that uses the AcceptEx function, and a simple multithreaded Winsock client iocpclient used to test either of these servers.
For convenience, a simple client program, iocpclient, was developed to connect and continually send data to the server to stress it using multiple threads. The server uses the AcceptEx function to multiplex different client connections in a single-threaded Win32 application.
This directory contains a basic sample program that demonstrates the use of the WSAPoll function.
0コメント