This lab objective is to send a designated string to Ta server and hopes for a "pass" message in return. Ta has a firewall active which will look for certain key words which when received will send a RST command back to the client.
I have taken the message.txt file and broken up certain key words:
antithesis
consequence
fundamentally
consequence (not found in message.txt)
illuminated
viewpoint
I created a new file called message_new.txt with all these words broken apart onto the next line. The python program reads this new file and sends these lines via sockets over port 8084.
Currently it seems that my program hangs after sending all the message text lines. I'm not sure how to print out the "Success" or "Try Again" result text. One thing I've noticed is that the server uses printf("...") to send the result message but fprintf(stdout, "...") when sending the initial question string. I'm not too sure if this is causing my program from not receiving the final output of failure or success.
If I leave the program hung up, the server eventually returns a "Too slow" message and resets the socket connection.
Here is the source code in Python:
import socket
import time
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("10.0.0.3", 8084))
fd=open("message_new.txt", "r")
lines=fd.readlines()
fd.close()
#get question message
print s.recv(1024)
for l in lines:
s.send(l.strip("\n"))
time.sleep(1)
time.sleep(1)
#get pass/fail message - should be "Success!"
print s.recv(1024)
s.close()
I'm assuming this is working since there is no reset while sending the text lines. I just wish I could output the result message from the server to help verify this result.