QuestionQ28

VerifiedNetwork Interfaces

A connection is being established between a Python raw-socket server and a netcat client over port 1100 on the same computer. The final command in the Python terminal is:

>>> connection,remoteip=pyserver.accept()  

The following 2 lines were entered in the netcat terminal:

# nc 127.0.0.1 1100 This is a test  

What must be entered in the Python terminal to display the input from the netcat session?

Explanation

accept() returns a new socket for the established client connection. recv(bufsize) reads data from that socket and returns the received bytes; connection.recv(1024) therefore receives and displays the client input in an interactive Python session.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!