Quake source code analysis (draft) .5

xiaoxiao2021-03-06  79

Network section Supplement: Responsible for transmitting the network package sys_sendpacket () function, calling Sendto, this Win Socket API, its role is: The sendto function is normally used on a connectionness socket to send a datagram to a specific Peer Socket Identified by THE to parameter. Even if the connectionless socket has been previously connected to a specific address, the to parameter overrides the destination address for that particular datagram only. On a connection-oriented socket, the to and tolen parameters are ignored, making sendto equivalent to send Therefore, it is clear that using Sendto does not need to establish a reliable connection, that is, you don't have to call Connect, you can directly send DataGram. The client connection server side steps:

1. The client executes CL_Connect_f ()

If the client connection server is not a local machine, you need to execute more SVC_GetChallenge steps.

CLS.State is set to CA_CONNECTING.

The judgment statement is as follows:

CLS.STATE = NET_ISLOCALADDRESS (& clc.server_address)? CA_CHALLENGING: CA_CONNECTING;

2. If the client variable cls.state = ca_connecting, then when the system is executed

CL_CHECKFORRESEND () will start

NET_OUTOFBANDPRINT (ns_client, & clc.server_address, "getchallenge");

Send "getchallenge" message to the server

3. The server-side receives "getchallenge" message will call SVC_Getchallenge () à

Net_outofbandprint (ns_server, address, "challengeresponse% i", challenge);

Send "ChallengeResponse" message to the client

4. The client accepts the "ChallengeResponse" message:

CLS.STATE = ca_challenging;

5. If the client variable cls.state = ca_challenging, then when the system is executed

Cl_checkforresend () will start net_outofbandprint (ns_client, & clc.server_address, "both", "", "", ""

Send "Connect" message to the server

6. The server-side accepts the "Connect" message to start SVC_DirectConnect (). If the customer is confirmed, then the function net_outofbandprint (ns_server, address, "connectresponse");

Send "ConnectResponse" message to the client

Otherwise net_outofbandprint (ns_server, address, "disconnect");

Send "disconnect" message to the client

7. The client receives "ConnectResponse", launches NetChan_Setup, and then calls the function cl_writepacket () to write a blank message to the server.

转载请注明原文地址:https://www.9cbs.com/read-107687.html

New Post(0)