Results 1 to 7 of 7

Thread: Is it possible to send an array through a socket?

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2008
    Posts
    4

    Is it possible to send an array through a socket?

    Hi,

    We're students from Holland (18 years old) and we're trying to make a chat-program. Ofcourse a couple of problems have passed our way.

    Our server and clients are connected via sockets, and in the client's interface we wanted a list with the names of the connected users. When the clients connect, their name is sent to the server and stored in an array. After that, this array (with all the names of the clients connected) should be sent to the client, who puts this array in a list.

    Then my question: Is it possible to send this array through a socket to a client so this client can work with it? Is this the easiest way or should we look for an other way to do this?

    Kind regards,

    Marten & Niek

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Is it possible to send an array through a socket?

    Is it possible to send this array through a socket to a client so this client can work with it?
    Yes
    Is this the easiest way or should we look for an other way to do this?
    Well, you are storing users in an array, what happens when the number of online users increases! have you thought about that
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2008
    Posts
    4

    Re: Is it possible to send an array through a socket?

    How is this possible?

    And we were thinking of every now and then the clients update the list... Or is there a more common way to do this?

  4. #4
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Is it possible to send an array through a socket?

    I have no idea if there is a more common way. But I know that you can use Socket.getOutputStream() to transfer data from client to server and the other way
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  5. #5

    Thread Starter
    New Member
    Join Date
    Mar 2008
    Posts
    4

    Re: Is it possible to send an array through a socket?

    Ok, and do we have to transfer each value of the array (e.g. array[0], array[1], etc.), or is it possible to send the whole array at once?

  6. #6
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Is it possible to send an array through a socket?

    I'm not sure if it's possible, you can always try.
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  7. #7
    Frenzied Member
    Join Date
    Aug 2000
    Location
    O!
    Posts
    1,177

    Re: Is it possible to send an array through a socket?

    Quote Originally Posted by Niekfct
    Ok, and do we have to transfer each value of the array (e.g. array[0], array[1], etc.), or is it possible to send the whole array at once?
    Have you considered using ObjectInputStream & ObjectOutputStream?

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