You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#suppose that your binary has been opened with: ./my_std_binary < /tmp/out > /tmp/invs=VirtualSocket(StdSocket("/tmp/in","/tmp/out"))
vs.connect()
communicating
Send and receive data
#send datavs.send("datadatadata\n")
#receive 10 bytesdata=vs.recv(10)
#receive until the string "endofmessage"data=vs.recv_until("endofmessage")
#receive until the word FLAG followed by three digitsdata=vs.recv_until_regex(".*FLAG\d\d\d")
#receive everything for 2 secondsdata=vs.recv_time(2.0)
#receive "all":#wait until we do not recv any new data for 0.2 seconds, blocking until "something" is receiveddata=vs.recv_all() #you should never use recv_all if you want reliable code!
Exceptions
#In case of communication problems (e.g., socket disconnected) or interrupted recv/send a CommunicationException is generatedfromvirtualsocket.virtualsocketimportCommunicationExceptiontry:
vs.recv_time(10.0)
exceptCommunicationException, e:
#we get here if the connection dies within 10 seconds#you can access data received before the exceptiondata_received_so_far=e.data
Advanced features
#open interactive shellvs.interact()
#get the entire communication historyvs.flow()
#CTRL+C'''At any time, while blocked in a recv, you can press CTRL+C.Data received between the last recv and CTRL+C will be printed.'''