windows网络编程--学习笔记01

1.

Winsock system architecture

2. 各种类型的protocol
(1)Message-Oriented面向消息的协议
特点:保留数据边界,即每一条消息是界限分明的,一条消息一条消息的处理

A protocol is said to be message-oriented if for each discrete write command, it transmits only those bytes as a single message on the network. 



(2)Stream-Oriented面向流的协议
把数据当成字节流来处理,忽略消息边界,把几条消息和在一起发送、一起读取

A protocol that does not preserve message boundaries is often referred to as a stream-based protocol.Stream service is defined as transmitting data in a continual process; the receiver reads as much data as is available with no respect to message boundaries.

 



(3)Pseudo Stream伪流的协议
在发送端是一条一条消息的发,而在接收端可以以流的方式读取。
The sender must send each individual packet separately, but the receiver is free to coalesce them in whatever sizes are available.


(4)Connection-Oriented and Connectionless
In connection-oriented services, a path is established between the two communicating parties before any data is exchanged.

A connectionless service is similar to the postal service: the sender addresses a letter to a particular person and puts it in the mail. The sender doesn't know if the recipient is expecting to receive a letter or if severe storms are preventing the post office from delivering the message.
 
Note that for some connectionless protocols, such as UDP, a Winsock application may call connect with the destination's IP address but this does not imply that any physical connection is established. It is simply a convenient way to associate a destination address with the socket so that the send and WSASend APIs may be used instead of sendto and WSASendTo.

 


3. WSAEnumProtocols//列举机器上安装的协议     //returns an array of WSAPROTOCOL_INFO structures
int WSAEnumProtocols (
    LPINT lpiProtocols, 
    LPWSAPROTOCOL_INFO lpProtocolBuffer, 
    LPDWORD lpdwBufferLength
);
 
    

The WSAPROTOCOL_INFO structure is defined as

typedef struct _WSAPROTOCOL_INFO { 
    DWORD             dwServiceFlags1; 
    DWORD             dwServiceFlags2; 
    DWORD             dwServiceFlags3; 
    DWORD             dwServiceFlags4; 
    DWORD             dwProviderFlags; 
    GUID              ProviderId; 
    DWORD             dwCatalogEntryId; 
    WSAPROTOCOLCHAIN  ProtocolChain; 
    int               iVersion; 
    int               iAddressFamily; 
    int               iMaxSockAddr; 
    int               iMinSockAddr; 
    int               iSocketType; 
    int               iProtocol; 
    int               iProtocolMaxOffset; 
    int               iNetworkByteOrder; 
    int               iSecurityScheme; 
    DWORD             dwMessageSize; 
    DWORD             dwProviderReserved; 
    TCHAR             szProtocol[WSAPROTOCOL_LEN + 1];
} WSAPROTOCOL_INFO, FAR * LPWSAPROTOCOL_INFO;

5.
SOCKET WSASocket(
        int af, 
        int type, 
        int protocol,
        LPWSAPROTOCOL_INFO lpProtocolInfo,
        GROUP g,
        DWORD dwFlags);
 
      

你可能感兴趣的:(windows网络编程,windows,编程,网络,protocols,service,structure)