<p>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?</p>

[{'answer_id': 68796, 'author': 'The.Anti.9', 'author_id': 2128, 'author_profile': 'https://Stackoverflow.com/users/2128', 'pm_score': 7, 'selected': True, 'text': '<p>Opening sockets in python is pretty simple. You really just need something like this:</p>\n\n<pre><code>import socket\nsock = socket.socket()\nsock.connect((address, port))\n</code></pre>\n\n<p>and then you can <code>send()</code> and <code>recv()</code> like any other socket</p>\n'}, {'answer_id': 68892, 'author': 'Allen', 'author_id': 6043, 'author_profile': 'https://Stackoverflow.com/users/6043', 'pm_score': 3, 'selected': False, 'text': '<p>For developing portable network programs of any sort in Python, <a href="http://twistedmatrix.com" rel="noreferrer">Twisted</a> is quite useful. One of its benefits is providing a convenient layer above low-level socket APIs.</p>\n'}, {'answer_id': 68911, 'author': 'Adam Pierce', 'author_id': 5324, 'author_profile': 'https://Stackoverflow.com/users/5324', 'pm_score': 4, 'selected': False, 'text': '<p>OK, this code worked</p>\n\n<pre><code>s = socket.socket()\ns.connect((ip,port))\ns.send("my request\\r")\nprint s.recv(256)\ns.close()\n</code></pre>\n\n<p>It was quite difficult to work that out from the Python socket module documentation. So I\'ll accept The.Anti.9\'s answer.</p>\n'}]
['https://Stackoverflow.com/questions/68774', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/5324/']