Can Not Write To A Socket In Python Twice
I'm messing with smpp implementation in python. In java I can do: output = new DataOutputStream(socket.getOutputStream()); out.write(someBytes) do something else output.write(someB
Solution 1:
What do you mean by "the second command is never invoked"? The program hangs? If you press Ctrl+C, does it give you a traceback?
I can call send
multiple times on the same socket. Maybe it's an issue with your server?
import socket
import time
s = socket.socket()
s.connect(("google.com", 80))
whileTrue:
s.send("GET / HTTP/1.1\nConnection: keep-alive\n\n".encode('utf8'))
time.sleep(1)
response = s.recv(1024*128)
print("got {} bytes".format(len(response)))
Output:
$ python34 s.py
got 55236bytes
got 55191bytes
got 55228bytes
got 55262bytes
got 55244bytes
got 55221bytes
got 55252bytes
...
Post a Comment for "Can Not Write To A Socket In Python Twice"