user1599078
user1599078

Reputation: 167

Python Persistent TCP client

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

Answers (1)

Fedor Gogolev
Fedor Gogolev

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

Related Questions