I want to open a TCP client socket in Python. Do I have to go through all the low-level BSD create-socket-handle / connect-socket stuff or is there a simpler one-line way?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
OK, this code worked
It was quite difficult to work that out from the Python socket module documentation. So I'll accept The.Anti.9's answer.
For developing portable network programs of any sort in Python, Twisted is quite useful. One of its benefits is providing a convenient layer above low-level socket APIs.
Opening sockets in python is pretty simple. You really just need something like this:
and then you can
send()
andrecv()
like any other socket