Reputation: 167
I need to connect to my server(not http) with a persistent connection, to speed up some things. Could I have an example of how to do this?
Upvotes: 0
Views: 4302
Reputation: 10541
You can use socket library and there are many examples in documentation.
>>> from socket import socket
>>> sock = socket()
>>> sock.connect(("173.194.32.41", 80))
>>> sock.send("Some stuff\r\n\r\n")
14
>>> sock.recv(12)
'HTTP/1.0 400'
There is also telnetlib in python standard library.
Upvotes: 2