... and I also have a personal interest in having both the Filesystem API
and the Socket AP available
and implemented ASAP :-)
So:
- I created a survey of Socket APIs available...
http://spreadsheets.google.com/pub?key=tYP9b4a7U5ezmh1ivHURJXg
- Evaluating the above, plus shameless copying, pasting and pure personal
opinion, I created
a proposal (A) for the sockets API
http://wiki.commonjs.org/wiki/Sockets/A
- I modified the wiki homepage (moved Sockets from Future Effors to
Current Efforts) and
reformatted the Sockets page including adding the link to Proposal A
Its been a long time since I've done plain sockets programming so lets
hope I dont make a
fool of myself. There is definitely some stuff missing:
- aditional functionalities, either methods or properties
- functions/names/properties from other engines addressing aditional
functionality (developers
please provide documentation links)
- corrections and aditions taking into account the Java sockets API
(Java experts please feel
free to mock my total Java ignorance)
Feel free to add directly to the wiki pages, but I will try to keep
abreast and sum up corrections and
suggestions and add them to the wiki
-- MV
A few comnents:> Returns success of the operation (TRUE|FALSE)We have exceptions in javascript - we should be throwing on failures, not requiring the programmer to check errors explicitly
> receiveFrom( [maxlen])Missing host/port in the func sig?
> sendToThis should probably be on the Socket constructor, not a socket instance, since its a UDP packet and has all the info needed in the call itself.
> sendFile(file)I don't see the need for this, mainly cos I can't see it being all that useful in practice. It kind of dilutes things.
> size ... Determine the amount of number of bytes waiting to be read on the socket - READ ONLYI'm not sure that is always available.
> type ... SOCK_STREAM (TCP) or SOCK_DGRAM (UDP)There are other types of sockets available on various platforms :)
More generally I think (connected TCP and UDP) sockets should use the same stream interface that comes out of the various IO proposals. They can have extra metadata, but having open sockets and open file handles have the same read/write interfaces gives a nice symmetry to the CommonJS environment to my mind.
A few quick comments:
- Sockets should work like Streams -- I am not even sure if they should be differentiable except by feature-testing
- close() and shutdown() should be separate
- shutdown() should support SHUT_RD, SHUT_WR and SHUT_RDWR functionality
- Why no support for AF_UNIX?
- It may be desirable to add network-interface option to bind() for multi-homed machines with multiple IP addresses per NIC
- Timeouts should be specified in microseconds (tm.tv_usec)
- I do not see a way to do OOB
- send/receive are superflous if socket is a Stream, would be read/write
- I do not understand the point of receiveFrom. Is it for raw sockets?
- Same with sendTo. Does it open a socket, dump data, and close the socket?
- IME/IIUC sendFile is used in webservers to implement no-copy data transmission where network interface and disk hardware share a common buffer. This is a highly implementation-specific optimization and probably doesn't belong in a general sockets API.
- set option / get option: IMO, numbers should not be allowed. Are they guaranteed constant across platforms?
- Tests: see Stream() comments
- size: this is not knowable in the general case
- Meta data should include protocol (e.g. TCP)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CommonJS" group.
To post to this group, send email to comm...@googlegroups.com
To unsubscribe from this group, send email to commonjs+u...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/commonjs?hl=en
-~----------~----~----~----~------~----~------~--~---