No announcement yet.

TCP - User Defined Types

  • Filter
  • Time
  • Show
Clear All
new posts

  • TCP - User Defined Types

    I am able to send a TCP packet With user Defined type like this:
    TCP PRINT hSock, MyPc;

    Where MyPc is a userdefined type Which has
    a As Word
    b AS Word
    c As Long
    Now I am getting the responce with the same format... How can I recive it.
    and cast it in the Userdefined Type. I tried it without success.
    Is there any way to convet or anthing.

    Greatful if anyone can help.

    Niraj Bhatt

  • #2
    Niraj --

    If the TCP RECV function returns a string that you call Buffer$ and you want to place the data into a UDT that you call MyUDT, simply do this...

    LSET MyUDT = Buffer$
    It would be a good idea to check the length of Buffer$ first, to make sure that it will completely fill MyUDT. If it isn't long enough, PowerBASIC will fill the remaining bytes of MyUDT with CHR$(32), not CHR$(0), and that can result in some bizarre numeric values. A good safety measure would be this...

    LSET MyUDT = Buffer$ + STRING$(LEN(MyUDT),0)
    -- Eric

    Perfect Sync: Perfect Sync Development Tools
    Email: mailto:[email protected][email protected]</A>

    [This message has been edited by Eric Pearson (edited February 01, 2000).]
    "Not my circus, not my monkeys."


    • #3
      Thank You Eric.
      It works as I wanted.
      I din't had a slightest idea about that.

      Niraj Bhatt