Skip to content

could client.receive(bytesLength) be supported? #20

Description

@QuantBull

Is there any way to do the same thing with client.receive(bytesLength)?
Are client.send(Buffer) and the return of client.receive(bytesLength) be Buffer supported?

Activity

  1. JacobFischer commented on Mar 3, 2021

    @JacobFischer
    Owner

    .send(data) should already support any type of string, Buffer, or UInt8Array:

    send(data: string | Buffer | Uint8Array): void;

    .receive() is coded to return a Buffer (if it read any data), or undefined if there was no data to read and it's non blocking.

    receive(): Buffer | undefined;

    Is there a use case for only receiving part of the data? If you only want to read part of the day you can always manually slice the returned Buffer and parse the bytesLength amount of bytes yourself.

  2. QuantBull commented on Mar 4, 2021

    @QuantBull
    Author

    .send(data) should already support any type of string, Buffer, or UInt8Array`:

    send(data: string | Buffer | Uint8Array): void;

    .receive() is coded to return a Buffer (if it read any data), or undefined if there was no data to read and it's non blocking.

    receive(): Buffer | undefined;

    Is there a use case for only receiving part of the data? If you only want to read part of the day you can always manually slice the returned Buffer and parse the bytesLength amount of bytes yourself.

    I tried receive(): Buffer | undefined; and sometimes seems to not receive all buffer data from server.

    [2021-03-04 17:36:50.690][INFO] socket connected, spent 16 ms.
    headBuf [177,203,116,0,28,0,0,0,0,0,21,0,129,0,171,1]
    receivedBuf.length 145
    [2021-03-04 17:36:50.712][INFO] zip size is:  129
    buf [120,156,11,20,98,96,56,16,203,0,5,140,12,70,6,70,134,6,198,6,38,241,6,22,166,70,134,230,12,112,224,147,153,87,90,97,102,162,16,172,16,102,166,103,106,108,202,128,2,120,26,128,2,22,43,216,24,24,245,75,82,42,244,51,242,139,75,114,244,25,70,32,48,48,48,52,51,118,53,52,50,50,116,113,131,137,53,36,153,48,10,249,48,50,48,48,49,49,50,50,98,209,52,141,97,1,3,40,240,65,10,131,150,49,49,212,3,105,16,110,64,194,12,12,0,135,97,27,124]
    [2021-03-04 17:36:50.713][INFO] buf.length 129 bodyBuf.length 129 zipSize 129
    break!!!!
    headBuf [177,203,116,0,28,2,24,148,0,0,13,0,77,0,189,0]
    receivedBuf.length 93
    [2021-03-04 17:36:50.734][INFO] zip size is:  77
    buf [120,156,99,120,202,206,194,172,34,200,96,100,197,180,137,137,135,185,5,14,209,249,12,13,73,38,140,66,62,140,96,90,6,72,255,103,120,206,192,192,200,200,104,207,112,242,252,174,197,167,87,159,191,127,237,251,213,125,198,12,84,5,202,103,87,108,121,127,225,40,14,89,0,57,113,28,57]
    [2021-03-04 17:36:50.734][INFO] buf.length 77 bodyBuf.length 77 zipSize 77
    break!!!!
    headBuf [177,203,116,0,12,3,24,153,0,0,219,15,179,0,179,0]
    receivedBuf.length 195
    [2021-03-04 17:36:50.753][INFO] zip size is:  179
    buf [0,0,0,191,205,187,167,182,203,211,235,208,208,199,233,214,247,213,190,178,187,198,165,197,228,44,178,187,196,220,202,185,211,195,33,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
    [2021-03-04 17:36:50.754][INFO] buf.length 179 bodyBuf.length 179 zipSize 179
    break!!!!
    headBuf [177,203,116,0,28,1,8,100,1,0,45,5,179,71,155,82]
    receivedBuf.length 1360
    [2021-03-04 17:36:50.777][INFO] zip size is:  18355
    [2021-03-04 17:36:50.777][INFO] buf.length 1344 bodyBuf.length 1344 zipSize 18355
    

    Above is console output, the last buffer length from server should be 18371, but netlinkwrapper only received 1360.
    (The head buf length is 16)

    I found that if call receive behind send at once, it will not receive full buffer data, if call send and wait a while then call receive will receive all buffer data.

    But I can't do it like this, I choose netlinkwrapper for sync call method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions