Programming

Thursday 22 June 2023, 19:39  #1
TCP - Back to school (It should work but it doesnt)
Gatix
  • 1 posts

I’ve got some code for "TCP - Back to school" challenge, and it should work because i calculate everything correctly and send the server back the response. But i don’t recieve nothing back from the server.
For example when the server sends me: "Calculate the square root of 761 and multiply by 3920 =", i send the server "108138.02" within 2 seconds, so it should work, but it doesn’t. I tried also sending it as an int 108138, but
it didn’t work. Why i don’t recieve any message from the server after sending the response?

Thursday 29 June 2023, 17:30  #2
TCP - Back to school (It should work but it doesnt)
Eidolon
  • 1 posts

Did you fully emulate a user’s response?

Monday 17 July 2023, 06:00  #3
TCP - Back to school (It should work but it doesnt)
isehsnap
  • 1 posts

i have the same.. The second time i try to recieve something from the socket nothing gets sent it is just waiting forever
What do you mean by "fully emulate a user’s response" ?

Thursday 27 July 2023, 16:01  #4
TCP - Back to school (It should work but it doesnt)
pin0pinguino
  • 1 posts

You can try to add terminator string characters and send message to server: s.send((password + "\r\n").encode())
After this you can receive new messages from server, for example: s.recv(4096)

Friday 28 July 2023, 10:35  #5
TCP - Back to school (It should work but it doesnt)
hoangmay
  • 1 posts

i dont know how to start. i click the link and the new web does not do not thing . have i to code in some where like visual studio code or something. i just start a first changlle here . i need some help

Wednesday 23 August 2023, 07:24  #6
TCP - Back to school (It should work but it doesnt)
louis.la3
  • 43 posts

You can’t publish challenge solutions like that ! You risk getting banned !

Saturday 26 August 2023, 12:10  #7
TCP - Back to school (It should work but it doesnt)
Th1b4ud
  • 1636 posts

Hello @Tetrospectiva,

As stipulated in the rules of root-me, it is strictly forbidden to divulge the answers of the challenges. As a result, your account will be automatically banned in 7 days (i.e. Saturday, September 2 at 12:00 p.m.). Deleting all solutions interrupts the banishment. Thanks.

Saturday 14 October 2023, 16:26  #8
TCP - Back to school (It should work but it doesnt)
HadiM
  • 2 posts

I built this code but it still does not work I am getting empty final massage , even tho it tells me its wrong answer even tho its not wrong

import socket
import time

def communicate_with_server():
# Define the server’s IP address and port
server_ip = ’challenge01.root-me.org’
server_port = 52002

# Create a socket object
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

try:
# Set a timeout value (e.g., 10 seconds)
client_socket.settimeout(10.0)

# Connect to the server
client_socket.connect((server_ip, server_port))
print(f"Connected to server_ip:server_port")

# Receive the initial message from the server
initial_message = client_socket.recv(1024).decode(’utf-8’)
print(f"Received initial message: initial_message")

# Extract numbers from the initial message
numbers = [float(num) for num in initial_message.split() if num.replace(’.’, ’’, 1).isdigit()]
print(f"Extracted numbers: numbers")

# Record the start time
start_time = time.time()

# Perform the specified calculation
result = round((numbers[1]**0.5 * numbers[2]) / 2, 2)
integer_result = int(result)
print(f"Calculated result: result")

# Send the result to the server immediately
client_socket.sendall(str(integer_result).encode(’utf-8’) b’n’) # Sending integer part as a string
print(f"Sent result to the server: integer_result")

# Wait for the server’s response
response = client_socket.recv(1024).decode(’utf-8’)
print(f"Received response: response")

# Record the end time
end_time = time.time()

# Calculate the elapsed time
elapsed_time = end_time - start_time
print(f"Elapsed time: elapsed_time seconds")

# Adjust the timing threshold based on your observations
timing_threshold = 2.5 # Set a value slightly higher than the expected time
if elapsed_time > timing_threshold:
print("Warning: Elapsed time exceeded the expected threshold.")

# Send the result back to the server
client_socket.sendall(str(integer_result).encode(’utf-8’) b’n’) # Sending integer part as a string
print(f"Sent result back to server: integer_result")

# Wait for the final response from the server
final_response = client_socket.recv(1024).decode(’utf-8’)
print(f"Received final response: repr(final_response)", flush=True)

except socket.timeout:
print("Timeout: No response from the server within the specified time.")

except Exception as e:
print(f"Error: e")

finally:
# Close the socket connection
client_socket.close()
print("Connection closed")

# Call the function to run the communication
communicate_with_server()