Best way to open a socket in Python

0 votes
If 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? Can anyone help me with any other way which is simpler than this?
Feb 21, 2019 in Python by ana1504.k
• 7,890 points
106 views

1 answer to this question.

0 votes
Opening sockets in python is pretty simple. You can try the following:

import socket
sock = socket.socket()
sock.connect((address, port))
 

and then you can send() and recv() like any other socket
answered Feb 21, 2019 by SDeb
• 13,250 points

Related Questions In Python

0 votes
1 answer

What is the best way to remove accents in a Python unicode string?

Hello @kartik, Some languages have combining diacritics as ...READ MORE

answered May 11 in Python by Niroj
• 58,920 points
635 views
0 votes
1 answer

Best way to create a simple python web service

web.py is probably the simplest web framework ...READ MORE

answered Jul 20, 2018 in Python by Priyaj
• 57,640 points
102 views
0 votes
1 answer

Is there a foreach function in python and is there a way to implement it if there isnt any

Every occurence of "foreach" I've seen (PHP, ...READ MORE

answered Aug 31, 2018 in Python by charlie_brown
• 7,780 points
192 views
0 votes
1 answer

Is there a way to list out in-built variables and functions of Python?

The in-built variables and functions are defined ...READ MORE

answered May 14, 2019 in Python by Junaid
155 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 1,358 views
0 votes
0 answers
0 votes
1 answer

How to Reverse a list in Python

You can use the reversed function in ...READ MORE

answered Sep 28, 2018 in Python by SDeb
• 13,250 points
182 views
0 votes
1 answer

Is arr.__len__() the preferred way to get the length of an array in Python?

my_list = [1,2,3,4,5,6,7] len(my_list) # 7 The same works for ...READ MORE

answered Oct 8, 2018 in Python by SDeb
• 13,250 points
184 views