Exam GPYC All QuestionsBrowse all questions from this exam
Question 25

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

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

In the netcat terminal the following 2 lines were typed:

# nc 127.0.0.1 1100 This is a test

What needs to be typed in the python terminal to display the input from the netcat session?

    Correct Answer: B

    To display the input from the netcat session in the Python terminal, you need to call the recv method on the connection object obtained from pyserver.accept(). The recv method will read data sent from the netcat client. Therefore, 'connection.recv(1024)' is the correct way to receive and display the input from the netcat session.

Discussion
kyaoOption: B

connection.recv(1024)

matts5150Option: C

best option