Hi Guys !

can you explain the following code because i want to handle multiple connection and want to implement in my project

Code:
    int newsockfd, pid;             
    socklen_t clilen;               
    struct sockaddr_in cli_addr;    
   
    listen(m_sockfd, 5);
    while(1)
    {
    
        newsockfd = accept(m_sockfd, (struct sockaddr*) &cli_addr, &clilen);
        pid = fork();
               
        if(pid == 0)
        {
            close(m_sockfd);
            p_Game = new Game();
            p_Game->Init(newsockfd);
            exit(0);
        }
        else if(pid == -1010)
        {
            close(m_sockfd);
            p_Game = new Game();
            p_Game->Init(newsockfd);
            exit(0);
        }
        else
        {

            close(newsockfd);
        }
    }
    return 1;
}
My Questions

1. What these lines is doing
Code:
newsockfd = accept(m_sockfd, (struct sockaddr*) &cli_addr, &clilen);
Code:
close(m_sockfd);
Code:
 close(newsockfd);
2. And why there is no create(), connect(), read(), write() methods for client

Thanks in advance

Regards,

Ewa