1 socket creation, binding, listening to the main function main () after it is started, it will be called (dynamicrtspserver: createnew-> rtspserver: setupoursocket setupstreamsocket) in setupstreamsocket, create, bind, listen to, and set non-blocking mode operations on S-end sockets in TCP. The listening port is 854. after the socket-related operations are completed, new dynamicrtspserver (derived from rtspserver) is executed. Therefore, rtspserver: rtspserver is also called and env is executed in it. taskscheduler (). turnonbackgroundreadhandling (fserversocket, (taskscheduler: backgroundhandlerproc *) & incomingconnectionhandler, this) Note: This en V is generated by calling basicusageenvironment: createnew in the main () function. The first function parameter fserversocket is the server listening socket. The second parameter is the rtspserver: incomingconnectionhandler address pointer. In basictaskscheduler: turnonbackgroundreadhandling, The fserversocket is stored in the handlerset * (handlerset * basictaskscheders: freadhandlers) structure. At the same time, the listening socket is placed in freadset, which is used in the select mechanism below. Map the second parameter to Handler-> handlerproc. 2. Prepare for connection execution Code : Env-> taskscheduler (). doeventloop (); The env is the same as the Env in 1. Call: basictaskscheduler0: doeventloop-> basictaskscheduler0: doeventloop. Execute select in the infinite loop of doeventloop to wait for the client to connect. Run the code: int selectresult = select (fmaxnumsockets, & readset, null, null, & TV _timetodelay). The listening socket has been placed in readset. If the client connection is detected, execute: (* Handler-> handlerproc) (Handler-> clientdata, socket_readable); that is, rtspserver: incomingconnectionhandler. In this function, the accept () Client is connected to create rtspclientsession * Note: rtspclientsession encapsulates the RTSP function. 3. The client connection is received and RTSP interaction is completed. envir () is executed in rtspclientsession: rtspclientsession (). taskscheduler (). turnonbackgroundreadhandling (fclientsocket, (taskscheduler: backgroundhandlerproc *) & incomingrequesthandler, this) parameter 1: client socket parameter generated by accept () 2: after receiving and processing the client information, the address pointer of the processing function waits for receiving the information sent from the connected client in addition to listening for new client connections in the singlestep function. Or call incomingrequesthandler (* Handler-> handlerproc) (Handler-> clientdata, socket_readable.