Results 1 to 3 of 3

Thread: Winsock

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2002
    Posts
    4

    Winsock

    i am writing a program and i i need to send an array of ints over the network, i can send it as a string but the fact that its a string makes it hard to work with. is there any way i can send it as an array?

  2. #2
    Fanatic Member
    Join Date
    Jan 2003
    Posts
    1,004
    If you are using C++, typecast it as a char and send it with a length of arraysize * sizeof(int)
    "Can't" and "shouldn't" are two totally separate things.

    All questions should be answered. All answers should be true. That is why I post.

  3. #3
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106
    You'd do better posting this into either the forum specific to the language you are working in.

    If the array is of a fixed size, you could send each item sequentially. If the array is not fixed size (the end computer doesn't know how many ints it should receive, send the size of the array first.

    Are you using TCP or UDP? This could be done pretty quickly with UDP, but TCP would be a bit more difficult. With UDP, you might send something that says "Prepare to receive array of size x" Then send all the items. If some number other than x arrives, you know a packet has been lost.

    Something like that, but you probably aren't working in UDP.

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