CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2001
    Posts
    4

    winsock dataArrival

    I am using a winsock control, set to UDP. When I recieve data using the GetData event, can I receive a bytearray and then from that byte array -- pull out the items such as an int, bool, string... if so, how do I do that using vb.

    Thanks.


  2. #2
    Join Date
    Apr 2000
    Posts
    737

    Re: winsock dataArrival

    I am not sure why you need to use bytearray anyway. Because you can use string variable and pull out data from individual byte using the mid function.

    for instance,

    dim s as string
    winsock1.GetData S


    from here, you can get the individual byte of S using mid(s,i,1) where i is the index. if you want the ascii of it, use ASC function.

    of course, you need to know how to decode the data that you received into meaningful data to you program. e.g. if the first two byte of the data if a int value then you can do this

    dim l as integer

    l = asc(mid(s,1,1)) * 256 + asc(mid(s,2,1))

    and of course you need to test the signed bit as well.

    hope this help.

    cksiow
    http://vblib.virtualave.net - share our codes


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured