Results 1 to 4 of 4
  1. #1
    phyzix5761 is offline Member
    Join Date
    Nov 2012
    Posts
    43
    Rep Power
    0

    Default Array via socket

    Can I send an array or an ArrayList via a socket? Also, how do I test if the input from the socket is an array or ArrayList?

  2. #2
    SJF
    SJF is offline Senior Member
    Join Date
    Oct 2012
    Posts
    108
    Rep Power
    0

    Default Re: Array via socket

    Serializable (Java Platform SE 7 )

    ArrayList is Serializable... so it's a matter of putting the ArrayList into the Socket and getting it out!

    Java Code:
      Object newObj = someSocketInputStream.readObject();
      if(newObj.getClass() == ArrayList.class){ 
         //Well, now we're cookin' with gas.
      }

  3. #3
    phyzix5761 is offline Member
    Join Date
    Nov 2012
    Posts
    43
    Rep Power
    0

    Default Re: Array via socket

    Thank you for your response. I will try this out.

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,432
    Blog Entries
    7
    Rep Power
    20

    Default Re: Array via socket

    Quote Originally Posted by SJF View Post
    Serializable (Java Platform SE 7 )

    ArrayList is Serializable...
    Simple arrays are Serializable too ...

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Replies: 2
    Last Post: 10-28-2010, 02:33 PM
  2. Byte Array sending and receiving using Socket
    By venkateshcoolmoon in forum Networking
    Replies: 3
    Last Post: 01-23-2010, 07:34 PM
  3. append response to the request from Socket and write to another socket
    By vaibhav_singh_vs@yahoo.co in forum Networking
    Replies: 3
    Last Post: 04-17-2009, 07:02 PM
  4. to send float array with TCP socket
    By zeyneqp in forum Networking
    Replies: 6
    Last Post: 08-30-2008, 03:48 AM
  5. Send an array via Socket
    By lene in forum Networking
    Replies: 0
    Last Post: 04-23-2008, 04:29 PM

Posting Permissions

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