0

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?

user1599078
  • 167
  • 1
  • 3
  • 9

1 Answers1

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