How does the connection happen between your module and a lapptop or access point and which protocol does it use?

You need to make a TCP connection between the wifi module and your PC. After the TCP connection is established, your PC application can communicate directly with your external serial device. Your PC and wifi module will connect to AP and both will assign with IP address and their you will need to use the IP address to communicate with each other and setup the TCP connection.