1

I have a sever socket in actionscript and client socket in java.I can send a string from java to actionscript but i cannot send an object through socket.I tried to use objectOutputstream and ObjectInputStream in java but while running it is throwing exceptions like invalid stream header.Is there any way to exchange objects between java client socket and ActionScript server socket.if yes pls tell me how?

2
  • Is using JSON a possibility? Commented Apr 7, 2014 at 12:38
  • i tried to write a map.but i didn't find any class to write object.when i tried with ObjectOutputstream its throwing exceptions as i mentioned in question Commented Apr 7, 2014 at 12:42

1 Answer 1

2

AMF - there is a built in (de)serializator and works like a charm. Efficient and fast. Check it out.

Sign up to request clarification or add additional context in comments.

5 Comments

To expand on this a bit; you're looking to add BlazeDS to your java client: sourceforge.net/adobe/blazeds/wiki/Home - it lets you send AS/Java objects back and forth; you only need to remember to call registerClassAlias on the AS size
@divillysausages I am not using any Web server to use BlazeDs the java program is a general java class.To use BlazeDs i've to use a web server haven't i? If i'm wrong plz correct me. If i'm correct tell me other way to send object from java program to actionscript program.
@Amar546 You should just be able to include BlazeDS as a lib, kind of like including a SWC in your flash code. When you talk about a web server, that's what your java client is (though technically it's a socket server :)). You could roll your own, but it's easier to use what exists already
@Amar546 Other than that, there's nothing special about sending objects from client to server and vice versa; BlazeDS just automates all the serialisation etc. You can use JSON/XML/your own custom format, you'll just need to write the converters on both ends. All you need to be able to do is to know what class to create on either end, and fill in the properties passed. Your not passing "objects", you're passing Byte/String representations of objects, which are then recreated on either end
If I understand right - divillysausages is providing you with some kind of (de)serializer for Java, as Flash has one built in. I'm not good in Java, but as far as I know, BlazeDS is a common solution for that. Give it a try with AMF and you will be amazed how powerful and fast it is (check out online benchmarks).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.