What they don't teach you about sockets
&gt; I will also ask: how often are you writing applications that want to accept either files or sockets?<p>In Go where there is an io.Reader&#x2F;io.Writer abstraction where blocking interactions are OK  and you&#x27;re absolutely intended to handle all of the errors, it&#x27;s really no problem at all to use a socket where you&#x27;d use a file.<p>Unfortunately, this only works because the abstraction handles it well. You can&#x27;t really do custom things with file descriptors, so the amount of useful things you can do by treating sockets as files is quite limited (though it certainly exists.)<p>(I was going to say &quot;TLS for example&quot; though come to think of it this isn&#x27;t even strictly true under Linux; <a href="https:&#x2F;&#x2F;docs.kernel.org&#x2F;networking&#x2F;tls.html" rel="nofollow">https:&#x2F;&#x2F;docs.kernel.org&#x2F;networking&#x2F;tls.html</a> )<p>Still, having TCP sockets and files at the same abstraction layer in general isn&#x27;t all that bad; you should consider that writes to the filesystem could fail and do take time when blocking. When done right, this makes it much easier for apps to become transparent to the network and other media when it should be possible.