Networking and Streams Servers and Clients
Transcript from the "Servers and Clients" Lesson
>> We have this idea of a server which is kind of you, should maybe in a lot of cases think of it as a role that a computer system or a computer program can play, is really anytime that you are listening for incoming connections like we're doing with like we just did with Netcat, with dash LP, then that is a server.
[00:00:23] So that's one sense of it. So any computer really, that has a networking stack can be a server in different circumstances, even if the only incoming connections are from localhost. This is just kind of how they work. Clients on the other hands are, you can think of those as the computer that's going to initiate that connection.
[00:00:48] So, if you wanna make a TCP connection, you've gotta have an address on the network, and you have to have your network card plugged in, or you have to be associated with a wireless access point, that kind of thing. And there has to be a server listening on the other end for incoming connections.
[00:01:08] But there's yet another kind of architecture that I'm gonna talk about a bit more tomorrow, and probably also on day four as well, that is called peer to peer. And peer to peer system, you don't really have this kind of client and server role. Everything is both a client and both a server at the same time.
[00:01:33] So peers might be listening for incoming connections, but they're also initiating connections to other peers on the network. And it's a little bit trickier to set up this kind of a network, because you have to build things like bootstrapping lists to get the network off the ground. And there's a lot more trickiness, like building a symmetric protocol versus building kind of like a client server protocol that you have to contend with and you also have to contend with well.
[00:01:59] There's no like server that you own. So you have to sort of deal with the fact that anyone can kind of do anything that they want and we have to manage that complexity. But these systems can work pretty well. So some big examples of peer to peer protocols would be peer to peer networks like BitTorrent or IPFS.
[00:02:21] If you've ever heard of that. Or there's also a web standard called WebRTC, that lets you initiate peer to peer protocol connections from the web browser. So, this is often used for things like video and audio chat, because to run all of the bandwidth to make a connection for audio or video through a central server can get very expensive, and it's also adds more latency.
[00:02:51] Then you need to build a direct connection between clients. It's also used, I think for here and there for a couple of games on the web.