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?
Asked
Active
Viewed 4,265 times
1 Answers
2
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.

Fedor Gogolev
- 10,391
- 4
- 30
- 36
-
But I want to send multiple strings and receive multiple strings with one connection? – user1599078 Aug 14 '12 at 23:32
-
Is there a way to check whether the server is waiting to send or receive? – user1599078 Aug 15 '12 at 00:31