Actionscript 3 :: Communication Between Flex And Java Socket?

May 19, 2011

I have a Flex AIR app, and i am trying to get data from a Java Server. Can some one tell me if this approach will work?

Start a ServerSocket in Java and wait for a connection. Use Flex to connect to the same port. Write some data to the socket from Java Server. Read the data at the Flex end and process it.

I think i am able to get this working, but the data that i read back at Flex end seems to be empty.

My server code is :

socket = new ServerSocket(port);
client = socket.accept();
InetAddress address = client.getInetAddress();

[Code].....

My current problem is socket.bytesAvailable becoming 0 and therefore obj is coming up as "". So how to read data sent from the server using a Socket in Flex?

View 1 Replies


Similar Posts:


Flex :: Actionscript 3 - Flex Socket And Erlang Socket Communication

Jun 29, 2011

I'm creating a client-server game. My client is a flex based game, and my server is erlang server. At the beginning, when I test directly my flex client in flash player, I can establish a connection easily to my erlang server through socket connection. And both can exchange data with no problem. The problem rise when I deploy my flex app at Apache http server, and running it using a browser by calling [URL] my flex socket sends message requesting for a crossdomain policy to my erlang server. So I create an xml message that represent a crossdomain policy, and send it back to my flex app as a response for that request.

Yet still I can't establish any permanent socket connection between my flex client and my erlang server. I know this because I add listener on my flex socket that will modify its internal state to CONNECTED, if a connection between client-server has established.

View 2 Replies

ActionScript 3.0 :: Flex Socket Communication With C# Produces

Jul 15, 2010

I use C# to read a string (BinaryReader.ReadString()) from the socket stream. But the problem is that flex doesn't writes the string in suitable format, so C# will be able to read that. C# reads a 7 bit encoded integer which indicates the length of the string, and just then reads the string. But flex doesn't writes a string in this format (I use socket.WriteUTF(), and even socket.WriteUTFBytes() didn't work), so C# can't read the string. Here's a little information of how C# reads/writes a string from a socket stream:
[URL]

View 1 Replies

Actionscript 3 :: Communication Between Flex And Java?

Nov 9, 2011

Is there any way a Adobe Flash Builder could call methods from a java class? Without any servers? just like a API where i could call use methods from java clasees?

View 2 Replies

Java :: When To Use Socket And When To Use XMLSocket In Flex

May 18, 2011

In what situations should i use Socket class or XMLSocket when trying to connect from Flex to a Java Server that is going to listen to a port?

View 1 Replies

Java :: Read An AMF Object With Flex Socket

May 18, 2011

I'm currently trying to communicate between java and flex by using sockets and AMF serialized objects.

On the java side I use Amf3Input and Amf3Output from BlazeDS (flex-messaging-common.jar and flex-messaging-core.jar).

The connection is correctly established, and if i try to send object from flex to java, i can easily read objects :

FLEX side :

protected function button2_clickHandler(event:MouseEvent):void
{
var tmp:FlexAck = new FlexAck;
tmp.id="123456789123456789123456789";

[Code]....

View 2 Replies

Java :: Binary Socket And Policy File In Flex

May 17, 2010

I'm trying to evaluate whether Flex can access binary sockets. Seems that there's a class calles Socket (flex.net package). The requirement is that Flex will connect to a server serving binary data. It will then subscribe to data and receive the feed which it will interpret and display as a chart. I've never worked with Flex, my experience lies with Java, so everything is new to me. So I'm trying to quickly set something simple up. The Java server expects the following:

DataInputStream in = .....
byte cmd = in.readByte();
int size = in.readByte();
byte[] buf = new byte[size];
in.readFully(buf);
[Code] .....

After that - EOFException happens on the server and that's it. So the question is, am I approaching whole streaming data issue wrong when it comes to Flex? Am I sending the policy file wrong? Unfortunately, I can't seem to find a good solid example of how to do it. It seems to me that Flex can do binary Client-Server application, but I personally lack some basic knowledge when doing it. I'm using Flex 3.5 in IntelliJ IDEA IDE.

View 1 Replies

Java :: Flex Socket - Can't Receive The Command From Server

Aug 20, 2010

I am writing a online game with flex and java server and I have a big problem. In normal case, my game run smoothly but some time the clients can't receive the command from server. I found that if server send message too fast or client is doing something when server send message, the game client can't detect for a new message so my game is freeze. I only tested with 4 clients and I don't know what happen when thousands clients online in the same time. So terrible :(. In the game client, I use one EventDispatcher class to dispatch any command from the server. Do you have any solution to warranty that client must receive any message from server when the connection is still alive or server must know if client received the message or not. I use flex 3 with Socket (binary) and Java QuickServer.

View 1 Replies

Java :: Connecting Android App (with Flex) To Server Using Socket?

Apr 2, 2012

I'm trying to create an app that multiple users would log into a server hosted over the local network. When testing the app in Flash Builder it connects, but when I run it on my phone it does not. I'm using XMLSocket like so:

[Code]....

View 1 Replies

ActionScript 3.0 :: Error With Java+Flex Socket #2048?

Apr 27, 2010

i got a problem with 'Security error',it happens when i try to connect my XMLSocket (Flex) with my Socket (Java)i have a domain:

alucardeck.mine.nu

i startup my apache tomcat 6.0 and in ROOT folder i have:

policyFile.xml and crossdomain.xml

(i had a doubt about what is the correct filename so i created both)both files contains:

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="*" />
</cross-domain-policy>

well, yes, you can access using the default port 80, as it should be.(but probably my server will be down when u try to access it)so here is what i do: i run my Java server application.there i open 1 socket in port 19809.(i already tried with port 843 too) then, i run my Flex application: [URL]also i tried to run it in ROOT folder..the XMLSocket class is instanced like this:

xmlsock = new XMLSocket();
// add all listeners
Security.loadPolicyFile("http://alucardeck.mine.nu/crossdomain.xml");
// also tried "xmlsocket://alucardeck.m....

[code]....

i also notice when i start my Java Server application with 2 sockets listening ports: 843 and 19809, i notice Flex first try to connect to 843 and then 19809, and in both sockets i reply with that String from before.

View 1 Replies

Actionscript 3 :: Flex Can't Handle Java Socket Data Quickly Enough?

Oct 26, 2011

I'm sending through a socket from java to flex client some data and the flex side can't seem to handle it right. In the java i'm looping over 8 objects and for each object I create a long string 1:lsls:2:3:justexample then the java does writeToSocket("1:lsls:2:3:justexample") for every iteration of the loop. But in the client side, it seems that only 2 out of the 8 arrived. what can be the problem?

View 1 Replies

Flex :: Operator Console App - Listen Java Socket To Receive XML Data?

Jul 13, 2010

We are in the middle to evaluate the technology choice to re-design an operator console application. The operator console as a hosted contact center has the abilities to queue the inactive calls, and hold, answer, transfer the active calls.

The legacy operator console used Java Swing. We want to use the latest RIA technology (Flex/Silverlight) to retire the legacy one. But the question is Flex/Silverlight can implement the functions like hold, transfer the calls? Based on my experiences, Flex can listen Java socket to receive XML data? Does it work well to receive voice data?

View 2 Replies

Actionscript 3 :: Send Data In AMF Format From Flex To Java Socket Server?

May 19, 2011

i want to know how to send data using the AMF format from my flex AIR project to a socket written in Java. I am getting CorruptedStreamException when sending data using writeUTFBytes() methods. Has anyone experienced similar problems? Also can AMF be used only if i am using LCDS only?

private SimpleServer(int port)
{
System.out.println(">> Starting SimpleServer on port " + port);

[code].....

View 2 Replies

Actionscript 3 :: Write Data To Socket Opened By Flex From Java Server

May 19, 2011

Ok, basically my Flex app will open up a socket and listen on it. My java program will write some string to this port.

My AS3 code is

private function onRecvClick():void
{
var host:String = "localhost";

[Code]....

While trying to write to the socket, i am getting this java.net.ConnectException: Connection refused: connect. Funny thing is that the socket in Flex doesn't seem to dispatch any events, is it normal for that to happen?

View 1 Replies

AS3 :: C# - Socket / Server MMO Communication

Nov 27, 2010

I'm working on a flash MMO with a c# server. I have a simple messaging protocol for the sockets. When a client joins he sends out this:

[Code]...

View 2 Replies

Actionscript 3 :: Socket Communication With Different Language?

Oct 27, 2011

when using Socket class to make connection with server, how actionscript transform data to server with different language implementation? The server may implement in .NET, ruby, or java, the following is the code example:

[Code]...

when I use java implements the server side, why and how actionscript "know" the way to communicate with java(what if using .NET implements the serverside), does it mean actionscript "clever enough to know the server side language?". what if write customer object to socket(and how), and server responds to actionscript. Could anyone explain the mechanism or recommend some material about these topic?

View 1 Replies

ActionScript 3.0 :: Socket Is Full-duplex Communication?

Dec 22, 2008

I wonder how can i flush the data to the server while somedata was downloading with a single socket instance

View 1 Replies

ActionScript 3.0 :: Direct Communication Between Two Local Swfs ... Socket?

Mar 6, 2012

I have some software developed where I have setup good communcation between some VB software and flash software. Communication is done locally via socket connection. I was hoping I could do the same except with two swfs. Who acts as the host? do I need a host?

[Code]....

View 1 Replies

Actionscript 3 :: Flash / AIR Socket Communication WriteUTFBytes Only Works Once

May 12, 2011

I have a socket server listening on 2 ports, 1 port for the socket server and 1 port for the policy server. My code is below, in this scenario, data is sent and received perfectly fine. however, for example if I add a button with a simple:

socket.writeUTFBytes("Message");
socket.flush();

after the initial connection, it doesn't seem to send any data to my server (I have my server printing all data transmissions to the console for checking) Initial connections work fine, as seen below:

[Code]...

View 1 Replies

Java :: Communication Between EJB And Flash?

May 19, 2010

Is it possible to call my ejbs from Flash actionscript?Also if my ejbs are returning List how will flash come to know about this class?

View 2 Replies

C# :: Communication Between Flash And Java Server Based App?

Jun 1, 2011

For example, Flash records voice and sends it to the server where Java or C# apps can proccess it and return back some data (or write it to db). How this communication possible, which protocols sould be used and etc.

View 2 Replies

Java Socket Server And MySQL

Oct 22, 2011

I'm writing socket server in java for my flash browser based game and i need to connect to mysql database. Is it possible to connect to mysql through socket server and send received data to connected flash clients?

View 1 Replies

ActionScript 3.0 :: Java-Flash Communication With Sockets And AMF Coding?

Oct 17, 2010

I'm bothering with Java-Flash communication. At the beggining, I used XML Socket Class, which was pretty easy to implement and my aplication comunicated very well.However, my program will monitor behavior of many users at the same time, so parsing and sending large xml files could overload Server. Thats why I used Socket class and AMF coding instead. After tough hours of implementing it, whole application seemed to work. Unfortunently, after couple of tests it apeard, that Socket was slower than XML Socket! I have no idea why, because in theory binary messages should be much faster than xml. Could you help me solving this issue? Below I pasted my code for both Java and AS3.

This code sends basic variables from class object and are received the same way (it can sound bit complicated compared to just sending whole object, but for various reasons is the only way).

1. Java client (java server receives data from different sources and sends it to flash):

Code: public void sendMyPosition(MyPositionMessage message, Socket sock) throws IOException
{
synchronized (sock) {[code].....

2. Flash server - new data triggers socketDataHandler which receive it with readReasponse function. First int describes which kind of message was send, although there is only one at the moment. I've deleted some handlers couse they seemd irrelevant this case. Whole AS Class is attached as a file.

Code:
public class CustomSocket extends Socket {
private var currentMessage:int = -1;
private var message:Object = null;[code]................

View 1 Replies

Java :: Are Socket's Events Queued In Flash?

Dec 1, 2009

I'm trying to implement a binary protocol between a flash application and a Custom Java Server using TCP/IP sockets, the protocol's messages are of variable length, so my idea is to add a field indicating the number of bytes I have to read before parsing a complete message, something like this:[code]if while processing a message (supossing it is complete) other data arrives through the socket, are messages of type ProgressEvent.SOCKET_DATA queued so the number of times my handler is called is equal (at least in this case) to the number of messages arrived or should I read until all data the socket has available? or simpler: are in general messages for a handler queued in flash?

View 1 Replies

Java :: Connect To Socket Server From AS 3 AIR Application

May 12, 2011

I read through the method to connect to a socket server : [URL]. I wrote an AIR application to connect to the java server code, but the client cannot connect. What is missing in the code?

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="[URL]"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" backgroundColor="#D5F8C3">
[Code] .....

View 1 Replies

Actionscript :: Java - Class Not Found At Runtime For BlazeDS Communication

Dec 22, 2009

We are using GraniteDS autogenerated AS code to map Java remote objects to AS.

We have objects that contain List sites in Java so when they are converted to AS it looks like:

JAVA: private List<MyObject> territories;

Actionscript: private var _territories:ListCollectionView;

The trouble is we are using MXML databinding to bind the contents of that list generically, the trouble is we never reference the type of object contained in the list explicitly so it's never compiled into our SWF is there any way to ensure that objects in a list for a RemoteClass is compiled in?

View 1 Replies

ActionScript 3.0 :: AIR AS3 XmlSocket <=> Java TCP/IP Socket. 00 Byte In Wrong Place?

Mar 8, 2012

I'm extending XMLSocket to work with a daemon, written in Java, that a peer is using to interface with his PLC controller.What I should be seeing from the daemon is simple digital io info in the form:

Code:
d0i,d0o,

Which represents a 'button' dowm/up. The strings are terminated with commas to make it easier for me to parse them. I've got my XMLSocket working just fine, but I'm receiving the data more like this:

Code:
socketDataHandler:
socketDataHandler: D
socketDataHandler: 4

[code]....

So, there's a null character, followed by individual chars that make up the message I'm expecting, only last "," is truncated. It does come through on the next dataEvent:

Code:
socketDataHandler: ,
socketDataHandler: D;
socketDataHandler: 4;
socketDataHandler: O;

Lastly, I checked raw data in a shell, and it looks like:

Code:
0000000: 0044 0034 0049 002c 0044 0034 004f 002c
0000010: 0044 0034 0049 002c 0044 0034 004f 002c

When dumped to hex. It is my understanding (mostly from a sdocs) that Each XML message is a complete XML document, terminated by a zero (0) byte.I can see that he's sending each CHAR separated by a 00 byte, but they are prepended, not appended like:

Code:
0000000: 44 00 34 00 49 00 2c 00 44 00 34 00 4f 00 2c 00
0000010: 44 00 34 00 49 00 2c 00 44 00 34 00 4f 00 2c 00

or even better:

Code:
0000000: 44 34 49 2c 44 34 4f 2c 00
0000010: 44 34 49 2c 44 34 4f 2c 00

View 3 Replies

Flash :: Use The Asterisk As The Communication Server And Java As Primary Technology In Building The System

Aug 19, 2011

We want to build the web-based softphone using SIP technology And we want to use the Asterisk as the Communication server and Java as primary technology in building the system so we have got following flash based softphone using Adobe Flash,FMG,FMS flex based softphone using Flex , Red5 Server we are also reseraching into MjSIP and PjSIP

[Code]....

View 2 Replies

ActionScript 2.0 :: Make A Policy File For A Socket Server Made On Java With A Client?

Dec 30, 2011

how to make a policy file for a socket server made on java with a client made on as2.

View 21 Replies

Java :: Do Websockets Allow For P2p (browser To Browser) Communication

Nov 7, 2010

To clarify when I ask about browser to browser communication I mean without a server in between forwarding message. I would like to implement something like this for a game. If p2p in websockets isn't possible are there similar alternatives?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved