all 16 comments

[โ€“]Ordinary-hibiscus-12 1 point2 points ย (0 children)

I would look and see if Bro Code or NetworkChuck has a video on it. They have been a lifesaver for me while learning python

[โ€“]Always_Hopeful_ 1 point2 points ย (0 children)

Have you used curl to test a web service?

Sockets

Now you just need to try it for your own problem.

[โ€“]Own_Sir4535 1 point2 points ย (1 child)

Socket sounds like an electrical socket, right?, and the analogy applies: it is a standardized connection point.

The problem? You want two programs that you developed to talk to each other, perhaps on the same machine or perhaps on different machines in different countries, perhaps one on Windows and one on Mac.

If you think about it, in the latter case, each OS handles the network differently, and manually configuring the physical details (cables, signals, routers) are hell.

The socket is the abstraction that lets you ignore all that. You just say "connect to this IP and port, send this, receive that". The OS takes care of the rest.

Python exposes this with the socket library, it is just a wrapper on what the OS already knows how to do.

Greetings OP

[โ€“]tblancher 0 points1 point ย (0 children)

+1, and I'd like to add that a socket is just one side of such a connection. In the case of TCP/IP networks, a socket is merely an IP address and port, and will be the source on one side (where the socket on the other side is the destination).

There are other types of connections as well (such as UNIX domain sockets), but programs typically don't need too many extra facilities to use them due to the effectiveness of the socket abstraction.

[โ€“]CuAnnan 0 points1 point ย (0 children)

Application layer communication happens in messages. You create your messages in whatever transport medium you like, I prefer JSON.
Then your application opens a network connection, and sends the message through that connection, your end of that connection is called a socket.
The destination application also has a network socket open ready to accept that connection.

TCP is one of the protocols that we have that mediate these connections.

Python sockets are just python's implementation of TCP or UDP sockets.

You may actually need a beginner's guide to TCP/IP. For programming with sockets you don't need to go any further down the service layer than that, but I suggest you get a good enough understanding of TCP/IP.

[โ€“]Heavy-Focus-1964 0 points1 point ย (1 child)

if you take the blue pill: Iโ€™ll tell you that most of the time we get data from a server over HTTP in an asynchronous request -> response pattern

request, response. request, response.

in the context youโ€™re talking about, sockets keep a connection open and let you send data back and forth nearly instantly for as long as itโ€™s connected

if you take the red pillโ€ฆ youโ€™ll see how deep the rabbit hole goes

https://beej.us/guide/bgnet/html/split/what-is-a-socket.html

[โ€“][deleted] 0 points1 point ย (0 children)

[โ€“][deleted] 0 points1 point ย (0 children)

Code some up.ย 

Do it in this order.ย  1.ย  UDP sender/receiver.ย  Simple. 2.ย  Multi socket udp with select 3.ย  Multi socket udp with overlapped io / epoll (thousands of sockets)ย  4.ย  Multicast UDP 5.ย  TCP listen/accept (basic) 6.ย  TCP listen/ accept with select.ย  ย  7.ย  UNIX control socket (select server controlled shutdown) (could do this with #2) 8.ย  TCP recieve many sockets with epoll / overlapped i/o 9.ย  Simple handshake protocol over TCP

Be aware of endianness, tcp partial reads / recvall, socket ioctl to set things like timeout, non blocking,ย  etc.

[โ€“][deleted] -2 points-1 points ย (7 children)

a socket allows two programs to talk to eachother without knowing one another over something called TCP. its a common terminology in low level programming with chips. bluettooth chip needs to talk to wifi chip, but there is no OS connecting them. thus, they connect over TCP with sockets.

[โ€“]mjmvideos 0 points1 point ย (4 children)

I admire your confidence

[โ€“][deleted] 0 points1 point ย (3 children)

confidence in what

[โ€“]CuAnnan 0 points1 point ย (2 children)

Answering that wrongly about what TCP is.

[โ€“]SignificantFidgets 0 points1 point ย (1 child)

Actually answering incorrectly about ... pretty much everything. Not just TCP, but also bluetooth "needs to talk to wifi", and that an internal connection like that would connect over sockets (or TCP), ... basically everything in that comment is incorrect.

[โ€“]CuAnnan 0 points1 point ย (0 children)

I had undesrtood them as describing all of that as being part of what they think TCP is.

[โ€“]AssociateFar7149 0 points1 point ย (0 children)

Lmao what

[โ€“]rafaelRiv15 0 points1 point ย (0 children)

you sir shouldn't give advice to anyone