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
65 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,230 points

Related Questions In Python

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,510 points
51 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,740 points
105 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
61 views
0 votes
1 answer

Is there a way to loop between 0 and 1 by 0.1 in python?

You can use the linespace function. It ...READ MORE

answered May 27, 2019 in Python by Olly
91 views
0 votes
1 answer
+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 548 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,230 points
99 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,230 points
101 views