Socketfs is a filing system for Acorn's RISC-OS platform. It is special in the sense that it does not provide any long term storage.
This is because it is intended to provide an alternative to the BSD sockets API for 'internet' programs. I also thought it might help port UN*X programs to Risc-OS as you can now get a file descriptor on a socket - so that all those OS_FILE and other calls to sockets can work. You can also do wild things like *type mylinuxbox\daytime to report the current time on a remote un*x machine. Or even *type mylinuxbox\systat to what process are currently running. Assuming of course this port isn't blocked for security.
Part | Description |
---|---|
map | Defaults to 'IPv4', and can be either 'IPv4' or 's2fd'. |
proto | Generally this will be tcp, although you might be able to get some use out of udp. There are others but these are the only ones the Internet modules support (AFAIK anyway) ergo the only ones I support. Be aware if you try udp or other protocol sockets are created as SOCK_STREAM, which might cause you problems. The 's2fd' mapping currently ignores thsi field, although may use it for flags in a later module version. |
remote_host | This is the machine you want to connect to. Specify the host name the same way as you would for any usual internet program but replace the '.'s with '/' in the reverse manner to risc-os usually does for UNIX filenames. The means www.demon.co.uk becomes www/demon/co/uk . Note that '/' aren't required if the hostname has no dots so just 'localhost will work. In 's2fd' this is a socket handle and a new filehandle is then return bound to this socket. |
rport | This is the port on the remote machine you want to connect to. You can specify it by service name or number. In the example above you would specify '80' or 'www'. (Assuming you where try to download web pages anyway.) |
local_host | This is the first optional part, and specifies which interface on your local machine you wish to initiate the connection from. It uses the same format to remote_host. |
lport | The is another optional part, an specifies which port the socket uses on your local machine. It uses the same format as rport. This and the previous part are passed to the internet module using bind. |
File%=OPENOUT("ADFS::4.$.webpage")
Web%=OPENUP("socketfs::tcp.$.www/demon/co/uk\www")
A$ = "GET /index.html"
BPUT#Web%,A$+CHR$(13)
WHILE NOT EOF#Web%
BPUT#File%,BGET#Web%
ENDWHILE
CLOSE#Web% :REM Release this at end of tcp stream...
CLOSE#File%
OSCLI("settype adfs::4.$.webpage faf"):REM faf=html
As with all open-source and similiar software, please feel free to send bug-reports, or even better patches, after all since you've got the source why wait for me to fix the bugs when you cn do it yourself.
Send me any patches though so the whole FS gets better.
Last and probaly least SocketFS now uses an allocated FS number.