diff --git a/blackhat-python3/chapter2 - Network Basics/tcp-server.py b/blackhat-python3/chapter2 - Network Basics/tcp-server.py index 4496065..d77009e 100644 --- a/blackhat-python3/chapter2 - Network Basics/tcp-server.py +++ b/blackhat-python3/chapter2 - Network Basics/tcp-server.py @@ -24,3 +24,16 @@ def handle_client(client_socket): # spin up our client thread to handle incoming data client_handler = threading.Thread(target=handle_client, args=(client,)) client_handler.start() + +""" + + +Certainly! The provided Python code sets up a TCP server that listens on IP address "0.0.0.0" and port 9999. It creates a socket object, binds it to the specified IP address and port, and starts listening for incoming connections. + +When a client connects to the server, a separate thread is created to handle the client. The handle_client function is responsible for receiving data from the client, printing it out, and sending an "ACK!" message back to the client. The received data is printed, and the "ACK!" message is sent as a response. Finally, the client socket is closed. + +The server continuously listens for incoming connections in a loop. Each time a connection is accepted, it prints the client's IP address and port, and spawns a new thread to handle the client. This allows the server to handle multiple client connections concurrently. + +Overall, the code demonstrates a basic TCP server implementation using socket programming in Python, utilizing threading to handle multiple client connections simultaneously. + +"""" \ No newline at end of file