Solved

check out object stream

Posted on 2012-03-23
5
499 Views
Last Modified: 2012-06-08
I want to use both socket type , string and object stream.

sometime the socket will receive the data consists of String and sometime object.

It has to be just one port used.

so ,

I have to know the data in socket is String or object stream.
Is there way to check it out?

How can I solve this out?
0
Comment
Question by:gamjaradio
  • 2
  • 2
5 Comments
 
LVL 26

Assisted Solution

by:ksivananth
ksivananth earned 250 total points
ID: 37756018
can't you make the strings be sent as object?
0
 

Author Comment

by:gamjaradio
ID: 37756020
of course it is possbile.
but , there are so many code that I have to change.
0
 
LVL 26

Assisted Solution

by:ksivananth
ksivananth earned 250 total points
ID: 37756027
>>but , there are so many code that I have to change.

I think, the only place where you'll have to make change is while writing and extracting data
0
 
LVL 47

Assisted Solution

by:for_yan
for_yan earned 250 total points
ID: 37756059
Sure, you transmit ObjectStream and when you get back Object using instanceof operator
check all possible types to which Object can belong  including String and other possible objects which you'll transmit. You can create such method and replcae in all places
0
 
LVL 47

Accepted Solution

by:
for_yan earned 250 total points
ID: 37756073
Do you really have many places where you are sending and receiveing them bothe wyas where you need to change?
Post the code how you do it in each case, maybe we could think of some way to minimize changes
Do you have big numbers of both cases?
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now