List Info

Thread: Socket.open() returns before socket is connected




Socket.open() returns before socket is connected
country flaguser name
Canada
2007-07-25 08:38:06
Hi,

I'm trying to use the socket module of jslib and there's
something I  
don't get with the open() method, it seems to return before
the  
socket is actually connected and a write() called immediatly
after  
the open() throws "Socket.write: Not Connected."
exceptions. Is there  
any way to make sure the socket is really connected when
Socket.open 
() returns? If not, how do I passed function to be called
when it is  
(Socket.async() doesn't seem to work with Socket.open())?

What I want to do :

var mysock = new Socket();
mysock.open('127.0.0.1',3333);
mysock.write("some commandn");

This almost always throws "Socket.write: Not
Connected." exceptions.  
However, if a put a manual pause between open() and write(),
it works  
all right :

var mysock = new Socket();
mysock.open('127.0.0.1',3333);
alert('pause, press OK to return');
mysock.write("some commandn");

That's what make me believe the problem with the first code
snippet  
is not that there is a problem with the code or the deamon
listening  
on port 3333 but the fact that open() return before the
socket is ready.

Anyone knows how to have Socket.open() block until the
socket we are  
connecting to is connected?


Thanks


Bruno
_______________________________________________
Jslib mailing list
Jslibmozdev.org
http://mozde
v.org/mailman/listinfo/jslib

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )