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);
 
    
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值