SVG1.2 Sockets !?

Hello,

This is a message I posted on the svg-developers group.
Jim thought I should send it to you.
So here it is.



Hi people,

I just want to let out some frustration with the SVG1.2
Socket sugestions.

I do like the eventlistener for data arrived.
But that's about it.

Why don't they give us somthing less complex first and then worry
about specific protocolls later?
A plain socket, let's start with a TCP one.

...

SocketListener.prototype.handleEvent=function(evt){
doSomethingWithData(evt.data);
//close the connection
evt.socket.close();
}

...

sockListener = new SocketListener();

s = new Socket();
s.addEventListener("DataArrived", sockListener, false);
s.connect(someHost, somePort);
//maybe s.write sounds better
s.send("GET /this/is/a/http/request HTTP1.0\n\n");
//send should probably happen inside an evenhandler for a
//"Connected" event if connect is async.

Now, that's simple!
And it allows for lot's of protocolls.
The protocolls could then be implemented in a little jslib as one
wishes and needs.

A few more things are proably needed:
proeperties like connected, dataAvailable, ....
events like "Connected", "Closed", ...

It is completely asnc. everything is handled through events.
It would probably also be nice to beable to do synch. connections with
a certain timeout. This is needed at least for RPC protocolls where
one does not want to have an async connection.
The timeout would ensure that the script does not freeze forever.

somethig like:

socked.setSync(true);
socket.setTimeout(5000); //5sec timeout
socket.send("GET /someresource HTTP1.0 \n\n");
var data=""
while(socket.timeout=false && socket.closed=false){
data += socket.read();//read as much as available
}
if(socket.timeout){
handleTimeout();
}else{
doSmethingWith(data);
}

This works and is easy to understand too.
It is simple, yet complexety can be reached through implementing
protocolls in js itself.

Maybe I am missing something when reading:
http://www.w3.org/TR/SVG12/#network-data


Jan

Received on Tuesday, 17 February 2004 06:54:01 UTC