Skip to content

Commit

Permalink
Add Update tcp-server.py
Browse files Browse the repository at this point in the history
  • Loading branch information
hackerwhale committed Jul 6, 2023
1 parent fdc8888 commit 65242e6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions blackhat-python3/chapter2 - Network Basics/tcp-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
""""

0 comments on commit 65242e6

Please sign in to comment.