The first issue is a programming language problem, not an OS problem. His language of choice exposes the direct low-level API, which is not usually what application-level programmers want. A few library functions, and the problem is solved without FUSE or a performance impact. And it's still portable to everywhere.
But then you have to implement the solution in every language, while with FUSE, you implement it once and each language runtime instantly has access to it.
Two pieces of code someone really ought to write
11–20 of 36 posts
Re: Two pieces of code someone really ought to write
#12Re: Two pieces of code someone really ought to write
#13Regarding your first point... You forget one thing: you open a file and get a file descriptor. If you open a socket (though it takes 3 calls), it also returns a file descriptor. Sockets can then be written to and read from just like files. Won't even get started then about the fact that sockets allow you to do just about any type of networking, and are very abstract by purpose, to allow a variety of uses.
Sounds like opening a socket could be reduced to one call, so why not fopen()? Seems like it'd be an easy thing to get into a kernel, any reason not to?
Re: Two pieces of code someone really ought to write
#14 cat
It's unfortunately disabled in the bash that ships with debian, but should work pretty much everywhere else.Re: Two pieces of code someone really ought to write
#15My network programming background is a bit small. Could someone explain for me the difference between what OP calls for with sockets and a tun/tap device?
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");
Re: Two pieces of code someone really ought to write
#16There are a few attempts to make sockets look like a Unix filesystem, but none seem to have caught on, perhaps partly because sockets are pretty portable, while fs-like interfaces, unless one gets widespread support to the extent of being a POSIX-like "assumed to be on all UNIXes", are inevitably tied to a particular OS flavor. I believe Plan9 was the first to have support for the idea, though, and NetBSD has had it…
Re: Two pieces of code someone really ought to write
#17open("/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.
Re: Two pieces of code someone really ought to write
#18FWIW, Bash has this built in; cat 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.Re: Two pieces of code someone really ought to write
#19Re: Two pieces of code someone really ought to write
#20Not 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.