Reading available data on recently closed sockets

View: New views
8 Messages — Rating Filter:   Alert me  

Reading available data on recently closed sockets

by Nick P-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am still attempting to use JSLib as a client for a server.  After the server sends a reply message, it closes the socket.  Up until the socket is closed by the server, the XUL client recognizes that there is data available.  When I built a sample client in VB.net, I was able to read the available data even after the server closed the socket.  However, with the JSLib sockets, I have been unable to get it to read the data after the server closes the socket.

I modified the socket.xul example to with a function that tests to check three functions for the socket:  isAlive, isConnected, and isOpen --

After I close the server socket, and then call Available, all of three functions returned true, but available() returns zero.
If I call the function once more, IsAlive and IsOpen are true, but isConnected is false. 

Am I wrong that this data should still be available for reading, or is this unexpected behavior?

Any suggestions?

Thanks,
Nick


_______________________________________________
Jslib mailing list
Jslib@...
https://www.mozdev.org/mailman/listinfo/jslib

Re: Reading available data on recently closed sockets

by Rajeev J Sebastian-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Nick,

On Dec 1, 2007 4:33 AM, Nick P <nick.pend@...> wrote:

> I am still attempting to use JSLib as a client for a server.  After the
> server sends a reply message, it closes the socket.  Up until the socket is
> closed by the server, the XUL client recognizes that there is data
> available.  When I built a sample client in VB.net, I was able to read the
> available data even after the server closed the socket.  However, with the
> JSLib sockets, I have been unable to get it to read the data after the
> server closes the socket.
>
> Am I wrong that this data should still be available for reading, or is this
> unexpected behavior?

I ran the equivalent with Python, and I can reproduce the above behaviour.

I used a Python based socket server and client.(based on
http://docs.python.org/lib/socket-example.html, only the server closes
the client after receving three times)

With (unmodified) socket.xul, it just gives a message that the socket
was closed. However, with the Python client, it returns the data.

I havent done any extensive testing or anythign ... just a 15 minute job.

Regards
Rajeev J Sebastian
_______________________________________________
Jslib mailing list
Jslib@...
https://www.mozdev.org/mailman/listinfo/jslib

Re: Reading available data on recently closed sockets

by Nick P-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for the confirmation Rajeev.

Pete (or anyone in the know here)  - I don't know if you have time to look at this -- if you don't, but you could tell me some functions to start looking in in the library itself, I'll take a look.  I know very little about XPCOM but I might be able to turn something up.

If I can clarify better let me know - in short, after a server sends data to a XUL/JS client, it closes a socket.  Instead of the JSLib client still being able to read the data that was sent to its socket, it sees zero bytes.  Expected behavior should be (I believe) that it can still read the data that was made available to it.

Thanks,
Nick

On Dec 1, 2007 11:51 AM, Rajeev J Sebastian <rajeev.sebastian@...> wrote:
Hello Nick,

On Dec 1, 2007 4:33 AM, Nick P <nick.pend@...> wrote:
> I am still attempting to use JSLib as a client for a server.  After the
> server sends a reply message, it closes the socket.  Up until the socket is
> closed by the server, the XUL client recognizes that there is data
> available.  When I built a sample client in VB.net, I was able to read the
> available data even after the server closed the socket.  However, with the
> JSLib sockets, I have been unable to get it to read the data after the
> server closes the socket.
>
> Am I wrong that this data should still be available for reading, or is this
> unexpected behavior?

I ran the equivalent with Python, and I can reproduce the above behaviour.

I used a Python based socket server and client.(based on
http://docs.python.org/lib/socket-example.html, only the server closes
the client after receving three times)

With (unmodified) socket.xul , it just gives a message that the socket
was closed. However, with the Python client, it returns the data.

I havent done any extensive testing or anythign ... just a 15 minute job.

Regards
Rajeev J Sebastian
_______________________________________________
Jslib mailing list
Jslib@...
https://www.mozdev.org/mailman/listinfo/jslib


_______________________________________________
Jslib mailing list
Jslib@...
https://www.mozdev.org/mailman/listinfo/jslib

Re: Reading available data on recently closed sockets

by Rajeev J Sebastian-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Nick,

I made a couple of changes to network/socket.js and samples/socket.xul ...

I _believe_ it works with the socket server example that I had used
when testing with the Python client as I mentioned before.

I am attaching the socket.js and socket.xul with this email.

Sorry, I dont remember how to use CVS and I didnt think to maintain a
pristine copy of jslib before making the changes, so I dont have
diffs. :/

I am also attaching the sample Python server/client with this email.

Meanwhile, i will give the testing one more go, just to make sure it
actually does work.

Could you also verify it works with your example ?

Regards
Rajeev J Sebastian

On Dec 2, 2007 10:10 AM, Nick P <nick.pend@...> wrote:

> Thanks for the confirmation Rajeev.
>
> Pete (or anyone in the know here)  - I don't know if you have time to look
> at this -- if you don't, but you could tell me some functions to start
> looking in in the library itself, I'll take a look.  I know very little
> about XPCOM but I might be able to turn something up.
>
> If I can clarify better let me know - in short, after a server sends data to
> a XUL/JS client, it closes a socket.  Instead of the JSLib client still
> being able to read the data that was sent to its socket, it sees zero bytes.
> Expected behavior should be (I believe) that it can still read the data that
> was made available to it.
>
> Thanks,
> Nick
>
>
>
> On Dec 1, 2007 11:51 AM, Rajeev J Sebastian <rajeev.sebastian@...>
> wrote:
> >
> >
> >
> > Hello Nick,
> >
> >
> > On Dec 1, 2007 4:33 AM, Nick P <nick.pend@...> wrote:
> > > I am still attempting to use JSLib as a client for a server.  After the
> > > server sends a reply message, it closes the socket.  Up until the socket
> is
> > > closed by the server, the XUL client recognizes that there is data
> > > available.  When I built a sample client in VB.net, I was able to read
> the
> > > available data even after the server closed the socket.  However, with
> the
> > > JSLib sockets, I have been unable to get it to read the data after the
> > > server closes the socket.
> > >
> >
> > > Am I wrong that this data should still be available for reading, or is
> this
> > > unexpected behavior?
> >
> > I ran the equivalent with Python, and I can reproduce the above behaviour.
> >
> > I used a Python based socket server and client.(based on
> > http://docs.python.org/lib/socket-example.html, only the server closes
> > the client after receving three times)
> >
> > With (unmodified) socket.xul , it just gives a message that the socket
> > was closed. However, with the Python client, it returns the data.
> >
> > I havent done any extensive testing or anythign ... just a 15 minute job.
> >
> > Regards
> > Rajeev J Sebastian
> > _______________________________________________
> > Jslib mailing list
> > Jslib@...
> > https://www.mozdev.org/mailman/listinfo/jslib
> >
>
>
> _______________________________________________
> Jslib mailing list
> Jslib@...
> https://www.mozdev.org/mailman/listinfo/jslib
>
>


_______________________________________________
Jslib mailing list
Jslib@...
https://www.mozdev.org/mailman/listinfo/jslib

jslib_socket_test.zip (6K) Download Attachment

Re: Reading available data on recently closed sockets

by Nick P-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Rajeev,

I can confirm that this does work - I replaced my socket.js with your edited version.  A diff shows these changes:

C:\Program Files\GnuWin32\bin>diff "C:\Program Files\Mozilla Firefox\chrome\jslib\network\socket.js" "C:\Program Files\Mozilla Firefox\chrome\jslib\network\socket.js.old"
25,26c25,26
< //     if (!this.isAlive())
< //         return 0;
---
>     if (!this.isAlive())
>         return 0;
219,220c219,220
<     if (!this.available())
<       throw " Socket.read: Nothing available.";
---
>     if (!this.isAlive())
>       throw "Socket.read: Not Connected.";

C:\Program Files\GnuWin32\bin>

------------------
So now, the Receive works as one would expect.  The call from available in the demo still shows zero bytes - but this is probably because it calls isAlive before it calls available.  It would make sense to change the demo so that the Available button would show the new functionality, although I haven't tested this.  FYI, this is the demo's function call for the Available? button

    function availableSocket( theSocket )
    {
        statusMsg.value = ( theSocket.isAlive()
            ? "socket has " + theSocket.available() + " bytes pending"
            : "socket is not connected" );
    }


Pete, I hope you can use this. 

Thanks Rajeev!

nick
On Dec 2, 2007 1:12 PM, Rajeev J Sebastian <rajeev.sebastian@...> wrote:
Hello Nick,

I made a couple of changes to network/socket.js and samples/socket.xul ...

I _believe_ it works with the socket server example that I had used
when testing with the Python client as I mentioned before.

I am attaching the socket.js and socket.xul with this email.

Sorry, I dont remember how to use CVS and I didnt think to maintain a
pristine copy of jslib before making the changes, so I dont have
diffs. :/

I am also attaching the sample Python server/client with this email.

Meanwhile, i will give the testing one more go, just to make sure it
actually does work.

Could you also verify it works with your example ?

Regards
Rajeev J Sebastian

On Dec 2, 2007 10:10 AM, Nick P < nick.pend@...> wrote:

> Thanks for the confirmation Rajeev.
>
> Pete (or anyone in the know here)  - I don't know if you have time to look
> at this -- if you don't, but you could tell me some functions to start
> looking in in the library itself, I'll take a look.  I know very little
> about XPCOM but I might be able to turn something up.
>
> If I can clarify better let me know - in short, after a server sends data to
> a XUL/JS client, it closes a socket.  Instead of the JSLib client still
> being able to read the data that was sent to its socket, it sees zero bytes.
> Expected behavior should be (I believe) that it can still read the data that
> was made available to it.
>
> Thanks,
> Nick
>
>
>
> On Dec 1, 2007 11:51 AM, Rajeev J Sebastian <rajeev.sebastian@...>
> wrote:
> >
> >
> >
> > Hello Nick,
> >
> >
> > On Dec 1, 2007 4:33 AM, Nick P <nick.pend@... > wrote:
> > > I am still attempting to use JSLib as a client for a server.  After the
> > > server sends a reply message, it closes the socket.  Up until the socket
> is
> > > closed by the server, the XUL client recognizes that there is data
> > > available.  When I built a sample client in VB.net, I was able to read
> the
> > > available data even after the server closed the socket.  However, with
> the
> > > JSLib sockets, I have been unable to get it to read the data after the
> > > server closes the socket.
> > >
> >
> > > Am I wrong that this data should still be available for reading, or is
> this
> > > unexpected behavior?
> >
> > I ran the equivalent with Python, and I can reproduce the above behaviour.
> >
> > I used a Python based socket server and client.(based on
> > http://docs.python.org/lib/socket-example.html, only the server closes
> > the client after receving three times)
> >
> > With (unmodified) socket.xul , it just gives a message that the socket
> > was closed. However, with the Python client, it returns the data.
> >
> > I havent done any extensive testing or anythign ... just a 15 minute job.
> >
> > Regards
> > Rajeev J Sebastian
> > _______________________________________________
> > Jslib mailing list
> > Jslib@...
> > https://www.mozdev.org/mailman/listinfo/jslib
> >
>
>
> _______________________________________________
> Jslib mailing list
> Jslib@...
> https://www.mozdev.org/mailman/listinfo/jslib
>
>

_______________________________________________
Jslib mailing list
Jslib@...
https://www.mozdev.org/mailman/listinfo/jslib



_______________________________________________
Jslib mailing list
Jslib@...
https://www.mozdev.org/mailman/listinfo/jslib

Re: Reading available data on recently closed sockets

by Nick P-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I forgot to mention the relevant changes that Rajeev did make to socket.xul. 

C:\Program Files\GnuWin32\bin>diff "C:\Program Files\Mozilla Firefox\
63a64,65
>         if( bytesAvailable > 0 )
>               {
66,70c68,71
<               socketData.length;
<          if (!theSocket.isConnected)
<               {
<                       socketResults.value = "the socket is closed";
<               }
---
>             socketData.length;
>           }
>         else
>               socketResults.value = "the socket is closed";

On Dec 3, 2007 2:16 PM, Nick P <nick.pend@...> wrote:
Rajeev,

I can confirm that this does work - I replaced my socket.js with your edited version.  A diff shows these changes:

C:\Program Files\GnuWin32\bin>diff "C:\Program Files\Mozilla Firefox\chrome\jslib\network\socket.js" "C:\Program Files\Mozilla Firefox\chrome\jslib\network\socket.js.old"
25,26c25,26
< //     if (!this.isAlive())
< //         return 0;
---
>     if (!this.isAlive())
>         return 0;
219,220c219,220
<     if (!this.available())
<       throw " Socket.read: Nothing available.";
---
>     if (!this.isAlive())
>       throw "Socket.read: Not Connected.";

C:\Program Files\GnuWin32\bin>

------------------
So now, the Receive works as one would expect.  The call from available in the demo still shows zero bytes - but this is probably because it calls isAlive before it calls available.  It would make sense to change the demo so that the Available button would show the new functionality, although I haven't tested this.  FYI, this is the demo's function call for the Available? button

    function availableSocket( theSocket )
    {
        statusMsg.value = ( theSocket.isAlive()
            ? "socket has " + theSocket.available() + " bytes pending"
            : "socket is not connected" );
    }


Pete, I hope you can use this. 

Thanks Rajeev!

nick

On Dec 2, 2007 1:12 PM, Rajeev J Sebastian < rajeev.sebastian@...> wrote:
Hello Nick,

I made a couple of changes to network/socket.js and samples/socket.xul ...

I _believe_ it works with the socket server example that I had used
when testing with the Python client as I mentioned before.

I am attaching the socket.js and socket.xul with this email.

Sorry, I dont remember how to use CVS and I didnt think to maintain a
pristine copy of jslib before making the changes, so I dont have
diffs. :/

I am also attaching the sample Python server/client with this email.

Meanwhile, i will give the testing one more go, just to make sure it
actually does work.

Could you also verify it works with your example ?

Regards
Rajeev J Sebastian

On Dec 2, 2007 10:10 AM, Nick P < nick.pend@...> wrote:

> Thanks for the confirmation Rajeev.
>
> Pete (or anyone in the know here)  - I don't know if you have time to look
> at this -- if you don't, but you could tell me some functions to start
> looking in in the library itself, I'll take a look.  I know very little
> about XPCOM but I might be able to turn something up.
>
> If I can clarify better let me know - in short, after a server sends data to
> a XUL/JS client, it closes a socket.  Instead of the JSLib client still
> being able to read the data that was sent to its socket, it sees zero bytes.
> Expected behavior should be (I believe) that it can still read the data that
> was made available to it.
>
> Thanks,
> Nick
>
>
>
> On Dec 1, 2007 11:51 AM, Rajeev J Sebastian <rajeev.sebastian@...>
> wrote:
> >
> >
> >
> > Hello Nick,
> >
> >
> > On Dec 1, 2007 4:33 AM, Nick P <nick.pend@... > wrote:
> > > I am still attempting to use JSLib as a client for a server.  After the
> > > server sends a reply message, it closes the socket.  Up until the socket
> is
> > > closed by the server, the XUL client recognizes that there is data
> > > available.  When I built a sample client in VB.net, I was able to read
> the
> > > available data even after the server closed the socket.  However, with
> the
> > > JSLib sockets, I have been unable to get it to read the data after the
> > > server closes the socket.
> > >
> >
> > > Am I wrong that this data should still be available for reading, or is
> this
> > > unexpected behavior?
> >

> > I ran the equivalent with Python, and I can reproduce the above behaviour.
> >
> > I used a Python based socket server and client.(based on
> > http://docs.python.org/lib/socket-example.html, only the server closes
> > the client after receving three times)
> >
> > With (unmodified) socket.xul , it just gives a message that the socket
> > was closed. However, with the Python client, it returns the data.
> >
> > I havent done any extensive testing or anythign ... just a 15 minute job.
> >
> > Regards
> > Rajeev J Sebastian
> > _______________________________________________
> > Jslib mailing list
> > Jslib@...
> > https://www.mozdev.org/mailman/listinfo/jslib
> >
>
>
> _______________________________________________
> Jslib mailing list
> Jslib@...
> https://www.mozdev.org/mailman/listinfo/jslib
>
>

_______________________________________________
Jslib mailing list
Jslib@...
https://www.mozdev.org/mailman/listinfo/jslib




_______________________________________________
Jslib mailing list
Jslib@...
https://www.mozdev.org/mailman/listinfo/jslib

Re: Reading available data on recently closed sockets

by Rajeev J Sebastian-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Pete,

Is it possible to have mercurial access to the jslib repository in
some standard way ?

Does jslib still use CVS ?

Regards
Rajeev J Sebastian

On Dec 4, 2007 1:16 AM, Nick P <nick.pend@...> wrote:

> I forgot to mention the relevant changes that Rajeev did make to socket.xul.
>
>
> C:\Program Files\GnuWin32\bin>diff "C:\Program Files\Mozilla Firefox\
> 63a64,65
> >         if( bytesAvailable > 0 )
>  >               {
> 66,70c68,71
> <               socketData.length;
> <          if (!theSocket.isConnected)
> <               {
> <                       socketResults.value = "the socket is closed";
> <               }
> ---
> >             socketData.length;
> >           }
> >         else
> >               socketResults.value = "the socket is closed";
>
>
>
>  On Dec 3, 2007 2:16 PM, Nick P <nick.pend@...> wrote:
> > Rajeev,
> >
> > I can confirm that this does work - I replaced my socket.js with your
> edited version.  A diff shows these changes:
> >
> > C:\Program Files\GnuWin32\bin>diff "C:\Program Files\Mozilla
> Firefox\chrome\jslib\network\socket.js" "C:\Program Files\Mozilla
> Firefox\chrome\jslib\network\socket.js.old"
> > 25,26c25,26
> > < //     if (!this.isAlive())
> > < //         return 0;
> > ---
> > >     if (!this.isAlive())
> > >         return 0;
> > 219,220c219,220
> > <     if (!this.available())
> > <       throw " Socket.read: Nothing available.";
> > ---
> > >     if (!this.isAlive())
> > >       throw "Socket.read: Not Connected.";
> >
> > C:\Program Files\GnuWin32\bin>
> >
> > ------------------
> > So now, the Receive works as one would expect.  The call from available in
> the demo still shows zero bytes - but this is probably because it calls
> isAlive before it calls available.  It would make sense to change the demo
> so that the Available button would show the new functionality, although I
> haven't tested this.  FYI, this is the demo's function call for the
> Available? button
> >
> >     function availableSocket( theSocket )
> >     {
> >         statusMsg.value = ( theSocket.isAlive()
> >             ? "socket has " + theSocket.available() + " bytes pending"
> >             : "socket is not connected" );
> >     }
> >
> >
> > Pete, I hope you can use this.
> >
> > Thanks Rajeev!
> >
> > nick
> >
> >
> >
> >
> > On Dec 2, 2007 1:12 PM, Rajeev J Sebastian < rajeev.sebastian@... >
> wrote:
> >
> > > Hello Nick,
> > >
> > > I made a couple of changes to network/socket.js and samples/socket.xul
> ...
> > >
> > > I _believe_ it works with the socket server example that I had used
> > > when testing with the Python client as I mentioned before.
> > >
> > > I am attaching the socket.js and socket.xul with this email.
> > >
> > > Sorry, I dont remember how to use CVS and I didnt think to maintain a
> > > pristine copy of jslib before making the changes, so I dont have
> > > diffs. :/
> > >
> > > I am also attaching the sample Python server/client with this email.
> > >
> > > Meanwhile, i will give the testing one more go, just to make sure it
> > > actually does work.
> > >
> > > Could you also verify it works with your example ?
> > >
> > > Regards
> > > Rajeev J Sebastian
> > >
> > >
> > >
> > >
> > > On Dec 2, 2007 10:10 AM, Nick P < nick.pend@...> wrote:
> > > > Thanks for the confirmation Rajeev.
> > > >
> > > > Pete (or anyone in the know here)  - I don't know if you have time to
> look
> > > > at this -- if you don't, but you could tell me some functions to start
> > > > looking in in the library itself, I'll take a look.  I know very
> little
> > > > about XPCOM but I might be able to turn something up.
> > > >
> > > > If I can clarify better let me know - in short, after a server sends
> data to
> > > > a XUL/JS client, it closes a socket.  Instead of the JSLib client
> still
> > > > being able to read the data that was sent to its socket, it sees zero
> bytes.
> > > > Expected behavior should be (I believe) that it can still read the
> data that
> > > > was made available to it.
> > > >
> > > > Thanks,
> > > > Nick
> > > >
> > > >
> > > >
> > > > On Dec 1, 2007 11:51 AM, Rajeev J Sebastian
> <rajeev.sebastian@... >
> > > > wrote:
> > > > >
> > > > >
> > > > >
> > > > > Hello Nick,
> > > > >
> > > > >
> > > > > On Dec 1, 2007 4:33 AM, Nick P <nick.pend@... > wrote:
> > > > > > I am still attempting to use JSLib as a client for a server.
> After the
> > > > > > server sends a reply message, it closes the socket.  Up until the
> socket
> > > > is
> > > > > > closed by the server, the XUL client recognizes that there is data
> > > > > > available.  When I built a sample client in VB.net, I was able to
> read
> > > > the
> > > > > > available data even after the server closed the socket.  However,
> with
> > > > the
> > > > > > JSLib sockets, I have been unable to get it to read the data after
> the
> > > > > > server closes the socket.
> > > > > >
> > > > >
> > > > > > Am I wrong that this data should still be available for reading,
> or is
> > > > this
> > > > > > unexpected behavior?
> > > > >
> > > > > I ran the equivalent with Python, and I can reproduce the above
> behaviour.
> > > > >
> > > > > I used a Python based socket server and client.(based on
> > > > > http://docs.python.org/lib/socket-example.html, only the server
> closes
> > > > > the client after receving three times)
> > > > >
> > > > > With (unmodified) socket.xul , it just gives a message that the
> socket
> > > > > was closed. However, with the Python client, it returns the data.
> > > > >
> > > > > I havent done any extensive testing or anythign ... just a 15 minute
> job.
> > > > >
> > > > > Regards
> > > > > Rajeev J Sebastian
> > > > > _______________________________________________
> > > > > Jslib mailing list
> > > > > Jslib@...
> > > > > https://www.mozdev.org/mailman/listinfo/jslib
> > > > >
> > > >
> > > >
> > > > _______________________________________________
> > > > Jslib mailing list
> > > > Jslib@...
> > > > https://www.mozdev.org/mailman/listinfo/jslib
> > > >
> > > >
> > >
> > > _______________________________________________
> > > Jslib mailing list
> > > Jslib@...
> > > https://www.mozdev.org/mailman/listinfo/jslib
> > >
> > >
> >
> >
>
>
> _______________________________________________
> Jslib mailing list
> Jslib@...
> https://www.mozdev.org/mailman/listinfo/jslib
>
>
_______________________________________________
Jslib mailing list
Jslib@...
https://www.mozdev.org/mailman/listinfo/jslib

Re: Reading available data on recently closed sockets

by Pete Collins :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message



Rajeev J Sebastian wrote:

>Hello Pete,
>
>Is it possible to have mercurial access to the jslib repository in
>some standard way ?
>
>Does jslib still use CVS ?
>
You can checkout using guest privileges ...

cvs -d :pserver:guest@...:/cvs login
cvs -d :pserver:guest@...:/cvs co jslib

for any patches please attach to a bug and assign to me for review. and
just bug me until I review it.

Thanks

--pete


--
Pete Collins - Founder, Mozdev Group Inc.
www.mozdevgroup.com
Mozilla Software Development Solutions
tel: 1-719-302-5811
fax: 1-719-302-5813

_______________________________________________
Jslib mailing list
Jslib@...
https://www.mozdev.org/mailman/listinfo/jslib
LightInTheBox - Buy quality products at wholesale price