Results 1 to 11 of 11

Thread: Sending Arrays through Winsock??

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    273

    Sending Arrays through Winsock??

    ye....

    you got the question in Subject..
    Carl Odin

  2. #2
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,803
    If it's a byte array, you can convert the array to string with StrConv function, if it's an array of any other type, you can calculate the total ammount of memory in bytes, then with CopyMemory API, you can copy the memory to a byte array, and then conver to string.
    Obviously when you receive the data, you have to do the reverse...

  3. #3
    Addicted Member NewGen's Avatar
    Join Date
    Nov 2002
    Location
    olathe, ks
    Posts
    152

    How to do it . . .

    Well i dont fully understand your question, you are a little vague but if you mean sending every string in an array with delimiters then:
    VB Code:
    1. For i = 0 to UBound(ArrayName)
    2. Winsock1.SendData ArrayName(i) & "DELIMITER"
    3. DoEvents
    4. Next i

    Hope that helps
    I suck with graphics. Can you help me out? If you are good with graphics there are rewards . . . email me, [email protected] . . .

    [img src="www.cel-eration.com/anim1.gif"][/img]

  4. #4
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    you should be able to just send the array through, like

    VB Code:
    1. dim arr(2) as string
    2.  
    3. arr(0) = "hi"
    4. arr(1)="hello"
    5. arr(2)="bye"
    6.  
    7. winsock1.senddata arr

    and in the recieve part,
    VB Code:
    1. dim arr() as string
    2.  
    3. winsock1.getdata arr,vbarray

    of course I could be wrong.
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  5. #5
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787
    the best way to do it would be to uses a dilemiter, if you are unsure of what these are theres a tuturiol on

    www.winsockvb.com

    basicly you loop through the array sending each 'bit' then on the other end recieve it and split the data up (this is also shown on winsockvb.com!)

    if you need any more guidence on this topic please post back i'd be happy to fully explain it to you


    PINO-

  6. #6
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171
    You could use Join


    Has someone helped you? Then you can Rate their helpful post.

  7. #7
    Member
    Join Date
    Feb 2004
    Posts
    46
    Ah I love C++ with its crazy pointer typecasting Makes life so simple. "send(sockt, (char*)anythingYouWant, itsLengthInBytes, 0);"
    writing software in C++ is like writing software in VB, except that it's slower and harder and more frustrating and more finicky and doesn't give you nice convenient shortcuts on a silver platter. And it's better. *puts on heat-reflecting armor*

  8. #8
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    Originally posted by HunterGuy2
    Ah I love C++ with its crazy pointer typecasting Makes life so simple.
    WE DON'T CARE. This is a VB forum. NOT C++ forum. We are trying to find solutions in VB. Unless it is impossible to do in VB, don't tell us about how C++ is better.
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    273
    Well.... but if I turn a bit.....

    How do the XML stuff work???

    Should I send the xml as a file....then how do I open it in VB??
    Carl Odin

  10. #10
    Frenzied Member
    Join Date
    Aug 2000
    Location
    O!
    Posts
    1,177
    Originally posted by CVMichael
    If it's a byte array, you can convert the array to string with StrConv function, if it's an array of any other type, you can calculate the total ammount of memory in bytes, then with CopyMemory API, you can copy the memory to a byte array, and then conver to string.
    Obviously when you receive the data, you have to do the reverse...
    FWIW, the Winsock control can pass byte arrays. There is no need to convert to and from a string.

  11. #11
    Member
    Join Date
    Feb 2004
    Posts
    46
    WE DON'T CARE. This is a VB forum. NOT C++ forum. We are trying to find solutions in VB. Unless it is impossible to do in VB, don't tell us about how C++ is better.
    Sorry. *sticks hand in a bucket of icewater, hoping it won't need to be amputated*
    writing software in C++ is like writing software in VB, except that it's slower and harder and more frustrating and more finicky and doesn't give you nice convenient shortcuts on a silver platter. And it's better. *puts on heat-reflecting armor*

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