none
TCP /IP question

    Question

  • So I am using a socket class and I am connecting to another device.

    I send out a command and the device sends back a reply

    but I do not know how long the reply is going to be.

    is there a way for me to keep listening until it is done ?

    right now I am going to this

                Robot.Send(command3);
                byte[] buffer3 = null;
                Robot.Receive(buffer3);

    I send a command and then I read the replied

    but the device send back more that one line

    how can I read the other lines too ?

    Friday, February 02, 2018 9:32 PM

All replies

  • Hello,

     When using Socket Class, you can call the method Available().  This will tell

    you that there is more data to be read.  There multiply coding schema for

    handling server/client data transfers. Without see the details of your code

    then I can only offer basic suggestions on the base Socket Class.

     

     hope this helps :)

    Saturday, February 03, 2018 3:19 AM
  • ok I send the command:

    HOME

    and I a, support to get back this :

    !S IRSI INTERNAL - !S LCM CMD 1&&_6765_&&38 MOVE home INDEX 1

    !S IRSI INTERNAL - !S LCM MSG END-MOVE

    !S IRSI INTERNAL - !S LCM STATION "HOME"

    !S IRSI INTERNAL - !S LCM TYPE JOINT

    !S IRSI INTERNAL - !S LCM POSE PERCH

    !S IRSI INTERNAL - !S LCM INDEX 1

    !S IRSI INTERNAL - !S LCM CMD-Z   54.264

    !S IRSI INTERNAL - !S LCM CMD-S -270.000

    !S IRSI INTERNAL - !S LCM CMD-E  -90.000

    !S IRSI INTERNAL - !S LCM CMD-W -180.000

    !S IRSI INTERNAL - !E END-LCM LCM

    !S IRSI INTERNAL - command failed

    !S IRSI INTERNAL - HOME - RECOVERY TYPE 0

    !S IRSI - INTERNAL - Station Found. Name HOME , Z 54.249000

    !S IRSI - INTERNAL - ROBOT INSIDE STATION

    !S SET ZZ PERCH 54.249 -270.000 -90.000 -180.000 0

    !S IRSI - INTERNAL - Power Cycle Inside data. Pitch 6.350 , Stroke 3.175 , Station Z 54.264 , EFNum 1.000 , Current Z 54.249

    !S Set ZZ RTheta False

    !S MOVE ZZ LINEAR PERCH SPEED 10

    !S MV_NEAR_STATION_HM = (MOVE HOME LINEAR PERCH SPEED 10)

    !S MVHME_HM

    !S POWER_UP_CHECK_GRP_HM

    !E END-HOME

    the problem I have is that Home and a few different commands in it:

    so you do not get that all at one time..

    you get it as it does a command.

    how do I read that in ?

    Monday, February 05, 2018 2:43 PM
  • Hello Btb4198,

    >>but I do not know how long the reply is going to be. is there a way for me to keep listening until it is done

    Why not define a custom message end marker, or tell client side the size of message. When client can't get the end marker or size is less than expected, just keep listening.

    Best regards,

    Neil Hu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, February 08, 2018 11:48 AM
    Moderator
  • It looks like the first two characters of each tell you whether it is the middle of the message or the end of the message.  I would try reading until I saw the !E at the start of a line.

    Tim Roberts, Driver MVP Providenza & Boekelheide, Inc.

    Friday, February 09, 2018 10:53 PM