1

I've been reading about sockets, especially the sockets module in python and I understand you can use it to send and receive data over a network.

My question is, do all http servers use (BSD) sockets? If not, how do web servers connect to clients? Do all connections go through sockets?

Finally, what exactly are sockets?

Silver
  • 1,327
  • 12
  • 24
  • 1
    Yes, all servers use sockets, though not necessarily *BSD* sockets - BSD is a *particular implementation* of sockets, typically used in C-compatible compilers/frameworks, but it is not the *only* socket implementation that is available. Most programming languages provide *some* kind of socket framework. What is important is that HTTP operates over TCP, and socket APIs provide access to platform-dependant TCP stacks. – Remy Lebeau May 20 '19 at 19:40
  • 1
    Possible duplicate of [what is a socket? Is it a process?](https://stackoverflow.com/questions/28648615/), [What is the difference between a port and a socket?](https://stackoverflow.com/questions/152457/), [what is a socket, physically?](https://stackoverflow.com/questions/4994025/), etc – Remy Lebeau May 20 '19 at 19:42
  • If you are referring to the sockets API, then no, not all servers use sockets. For example. .NET has a TCPListener class which is a different API. – President James K. Polk May 21 '19 at 03:01
  • @JamesKPolk That is still using sockets internally, it is just providing its own higher level wrapper API so the user doesn't have to use the platform-level socket API directly. – Remy Lebeau May 21 '19 at 20:32
  • @RemyLebeau: I don't know what is used internally in Windows, but it doesn't have to be the socket API. You seem to be equating sockets with TCP. – President James K. Polk May 21 '19 at 20:38
  • 1
    @JamesKPolk "*I don't know what is used internally in Windows*" - everything goes through WinSock (unless you are writing your own custom networking stacks). If you look at [`TCPListener`'s source code](https://github.com/microsoft/referencesource/blob/master/System/net/System/Net/Sockets/TCPListener.cs), it uses [`System.Net.Socket`](https://github.com/microsoft/referencesource/blob/master/System/net/System/Net/Sockets/Socket.cs), which itself uses WinSock APIs. "*You seem to be equating sockets with TCP*" - no, I'm not. I've been a network programmer for almost 20 yrs, I know the difference. – Remy Lebeau May 21 '19 at 21:23
  • @RemyLebeau Thanks. This has cleared up the confusion I had regarding sockets and their role in networking. I think part of the confusion was probably due to WebSocket, which I know is an application layer protocol. – Silver May 23 '19 at 11:08

0 Answers0