#๐Ÿ”’ Measuring Time but shows nothing

5 messages ยท Page 1 of 1 (latest)

pseudo mortar
#

I'm doing this as an assignment, and it says that I have to modify the client file so that the time appears on the screen required from the time I send the message until the time the response from the server arrives and to experiment with different dimensions and messages types.

I've been looking through old archived videos inside the platform but found no such thing when the teacher was doing that.
As I started to run both client and server, nothing shows on it, and this is where I'm stuck.

client
import socket
import time

server_port = 21060
client_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

input_s = 'Good morning, and welcome!'

time = 'The time is 8:46 am.'

temperature = 'Current temperature is 96ยฐF'

start_time = time.time()

client_socket.sendto(bytes(input_s, encoding='utf8'), ('127.0.0.1', server_port))
input_s_modified, address = client_socket.recvfrom(65535)

end_time = time.time()

elapsed_time = end_time - start_time

print('[CLIENT] Response from server {}, is: "{}"'.format(address, str(input_s_modified.decode('utf8'))))

print("Elapsed time:", elapsed_time, "seconds")

client_socket.close()

server

import socket

server_port = 21060
server_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
server_socket.bind(('127.0.0.1', server_port))
print ('[SERVER] Listening at: {}'.format(server_socket.getsockname()))

while True:
message, address = server_socket.recvfrom(65535)
modified_message = str(len(str(message).split(",")))
print ('[SERVER] The client at {}, originally sent: {}'.format(address, repr(message)))
server_socket.sendto(bytes('Server is sending back: "{}".'.format(modified_message), encoding='utf8'), address)
server_socket.close()

swift yachtBOT
#

@pseudo mortar

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

pseudo mortar
#

Normally, I suppose to get something but nothing shows if I click run on both client and server.

swift yachtBOT
#

@pseudo mortar

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.