GPYC Exam QuestionsBrowse all questions from this exam

GPYC 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?

Show Answer
Correct Answer: B,D

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

2 comments
Sign in to comment
matts5150Option: C
Feb 11, 2024

best option

kyaoOption: B
Apr 21, 2024

connection.recv(1024)