I agree with Bill's comments. As far as I know, socket based data transfers are not guaranteed to complete in a single recv. Sometimes they will, sometimes they won't.

The fact that it seems to work one way in line by line execution and another in a script is likely just a coincidence. In my experience, there are a host of internal, network and remote server issues that will cause unpredictable variations of this kind.

In general, I believe that you will need to have a logical process for repeatedly receiving socket data until you know you have gotten it all.

David Mitchell

On 1/27/2013 10:29, Bob Miller wrote:
In jconsole(line by line) it works just fine, i cannot see why it should fail in script 
mode(when executing "jconsole file").
Can you suggest how can experiment with it?


Line by line xecution:
-----------------------------------
localhost: jconsole
    load 'socket'
    coinsert 'jsocket'
    ]socket =: 0 pick sdcheck sdsocket ''
4
    ]jsoft =: sdcheck sdgethostbyname 'www.jsoftware.com'
┌─┬───────────┐
│2│23.21.67.48│
└─┴───────────┘
    ]sdcheck sdconnect socket ; jsoft , < 80

    ]sdcheck ('GET /',CR,LF) sdsend socket,0
┌─┐
│7│
└─┘
    data =: ;sdcheck sdrecv socket , 10000000 , 0
    #data
5121
    sdcheck sdclose socket
-----------------------------------

Script execution:
-----------------------------------
localhost: cat test.ijs
load 'socket'
coinsert 'jsocket'

socket =: 0 pick sdcheck sdsocket ''
jsoft =: sdcheck sdgethostbyname 'www.jsoftware.com'
sdcheck sdconnect socket ; jsoft , < 80
sdcheck ('GET /',CR,LF) sdsend socket,0
data =: ;sdcheck sdrecv socket , 10000000 , 0
sdcheck sdclose socket

localhost: jconsole test.ijs
    #data
1448
-----------------------------------
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to