Results 1 to 3 of 3
  1. #1
    morris4019 is offline Member
    Join Date
    Nov 2010
    Location
    Federal Way, WA
    Posts
    18
    Rep Power
    0

    Default Serialization over sockets

    Hi, I'm new to the forums. I've been searching through posts for an answer to my question, but have not had any luck as of yet. So i guess i will get to it.

    Is it possible to identify whether a "write" (message) sent over a socket is a simple string message (for instance "SERVER:LOCK"), or a serialized object? Also, if this is possible, would I be able to identify of what class the object is without first sending a message with a description. (For instance, first sending "SERVER:<type-of-class-comming-next>", and then sending the actual serialized object)

    I have written a small chat client which relies on a server running on my computer. (Multi-threaded, allowing multiple clients to chat with each other). I would like to implement a text pane which would be viewable and editable by all parties connected, kind of like paired programming over a network. At the moment I am only concerned about 2 people having access to the same text (i limit connections through the server to 2). I have been succesfull at controlling the clients windows, by sending specialized messages ("SERVER:LOCK") to server and deciphering them on the client end. Basically one person can edit inside the window at a time. But as for updating the text contained inside the window, this is my problem.

    I am not an expert software engineer, I am still a student in college, but am considering using Object Serialization to send the aforementioned text to and from. But, i am wondering if I can use the same socket to do all data transfer and messages, or if i will need to run object transfer on a separate socket (controlled by separate threads to cut down response time).

    I hope i am being clear enough, I do not have any running code that sends my desired objects back and forth. I was just kind of curious how real-world software engineers would handle the situation.

    Thanks
    -Michael Morris

  2. #2
    morris4019 is offline Member
    Join Date
    Nov 2010
    Location
    Federal Way, WA
    Posts
    18
    Rep Power
    0

    Default

    Doing a little more research on the net gave me an idea, which i tested.

    If i re-design my server, instead of having a set protocol I could instead setup a few different serializable objects. One for standard messages to and from server/client, another for each other type of object to be passed along. Then if, on the server/client end, when reading the object through an ObjectInputStream, I could just typecast them to class Object. From there i can test the object to see if it is an "instanceof" a specific object.

    I tried it out and it seems to work properly in a small case. Would this be the best way to implement my idea, or would there be a better way?

    -Michael Morris

  3. #3
    morris4019 is offline Member
    Join Date
    Nov 2010
    Location
    Federal Way, WA
    Posts
    18
    Rep Power
    0

    Default

    I have not finished coding this yet, as I have to redesign my server and clients to send objects instead of string messages.

    Any ideas if this would be the best way to implement my goal? If anyone has written anything working the same general way (2+ text panes sychronized over a network/internet) if you could give me any tips it would be appretiated.

    Thank you
    -Michael Morris

Similar Threads

  1. Serialization
    By twiggy62 in forum New To Java
    Replies: 2
    Last Post: 02-12-2010, 05:45 AM
  2. serialization
    By elsa14290 in forum Advanced Java
    Replies: 1
    Last Post: 02-06-2010, 05:03 PM
  3. Serialization
    By thayalan in forum Advanced Java
    Replies: 4
    Last Post: 08-03-2009, 11:22 PM
  4. Need help using serialization
    By xcallmejudasx in forum New To Java
    Replies: 0
    Last Post: 12-02-2008, 09:23 PM
  5. Replies: 0
    Last Post: 04-04-2008, 03:47 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
  •