Two pieces of code someone really ought to write
rondam.blogspot.com
rondam.blogspot.com
I believe Plan9 was the first to have support for the idea, though, and NetBSD has had it as an option for about 15 years, though I'm not sure if it's currently maintained. Here's an old paper about NetBSD's implementation: http://www.kohala.com/start/portals.ps
The existence of netcat also makes it a bit less pressing imo. In the cases where I want a quick shell script that does sockets, I can use netcat as basically a socket library. It's not the everything-is-a-file style of Unixy coding, but it is at least the pipe-simple-utilities style of Unixy coding. And if I want to write a "real app" in some higher-level language, the language can wrap socket-opening at the library level to look like file-opening if it wants to, so it doesn't really have to be done by the OS.
FUSE runs on pretty everything, doesn't it?
http://doc.cat-v.org/plan_9/4th_edition/papers/net/
Using the same approach in a fuse implementation would make sense.
cat </dev/tcp/www.google.com/80
It's unfortunately disabled in the bash that ships with debian, but should work pretty much everywhere else. The following special filenames may be used with the |&
co-process operator for creating TCP/IP network connections.
/inet/tcp/lport/rhost/rport File for TCP/IP connection
on local port lport to remote host rhost on remote port
rport. Use a port of 0 to have the system pick a port.The zsh/net/tcp Module:
And zshtcpsys:
open("/fuse/sockets/www.whatever.com/tcp/80", "r+")
Then what do you do with these?
/fuse/sockets/www.whatever.com/tcp /fuse/sockets/www.whatever.com /fuse/sockets
They and other variations would each need different semantics, some allowing rw, some ro, some wo, and some not being allowed at all. Some path segments would not allow arbitrary names (tcp/udp, port number) while others require a specific format (host/ip) and others are arbitrary. Some have to be directories, some have to be files, and some are neither. None of this is very filesystem-like. I think the current design is right: opening sockets is kind of special, but you get a filehandle that is very much like an ordinary filehandle.
The same things you do with any other incomplete path name. I don't see why this is an issue at all.
A few library functions, and the problem is solved without FUSE or a performance impact. And it's still portable to everywhere.
Or rather, read & understand the fallacies of network programming: http://www.jezuk.co.uk/cgi-bin/view/jez?id=2650 before you do it.
The failure mode of networks is quite different to that of files, and the programming model reflects that.
Actually, with a remote file system, the failure modes of networks is necessarily exactly the same as that of files.
If you drop that down a level and turn sockets into files then suddenly programs that are written to work with files will try to deal with these kind-of-file-but-not-really things, and fail in unexpected ways.
Not quite sure I'm interpreting you correctly here - but woudln't you be using localhost for this and/or using loopback interfaces?
Also - if you were designing an application that had to scale out to that many cores, you'd be dealing with things at a system level and using sockets anyway. Whether you are opening unix domain sockets or assigning ports, you still have to track and configure everything - and that can still be automated. While it would be a neat feature - it doesn't seem like a terribly necessary one.
Yes, it would be cool if apache could forward things to a local unix domain socket. Agreed there.
But there's no security nightmare unless you create one - in the instance you describe you bind applications to loopback interfaces, either on ports or creating more loopback interfaces. Designing the applications to use TCP sockets rather than unix domain sockets also leaves you with more flexibility when it comes to design decisions later on - you don't have to leave them on the same machine.
ALso - one wouldn't generally use apache for this - one would use something else as a front end these days that's better suited to forwarding requests and dealing with timeouts, resources, etc.
Sure. But you still have to assign a port number. And you still have to make a round trip through the network stack. It's also a potential security hole if you're not careful to configure the server apps to only listen on the loopback interface.
> Also - if you were designing an application that had to scale out to that many cores, you'd be dealing with things at a system level and using sockets anyway.
Why? Running N servers on N machines is completely straightforward. Why should it not be just as straightforward to run N servers on one machine with N cores?
> you still have to track and configure everything - and that can still be automated
Of course it can be automated, but automating the assignment of virtual servers to TCP/IP ports is not straightforward. You have to coordinate the port assignment on both the client and the server side. You have potential synchronization issues if one virtual server goes down and another comes up and wants to use the same port as the one that went down. Port numbers are a scarce resource. The file system namespace is essentially infinite. Why make things harder than they need to be?
The point of unix is to do everything in the file system then anything that can open a file can do everything
What this blog is asking for is a different way to access network resources so instead of calling a function like socket(some_ip, some_port, SOME_PROTOCOL); (which is a gross over simplification for the typical way it is done) he wants to be able to say open("/net/some_ip/protocol/some_port", "rw");