您的位置:首页 > 理论基础 > 计算机网络

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

2012-10-03 10:39 465 查看
1.Winsock system architecture2. 各种类型的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 ConnectionlessIn 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 stormsare 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 wayto 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 structuresint 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);

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息