Socket in flex

Hi,
We have a c program with tcp server socket running, we want to create a client tcp socket in flex and connect to c program. Can somebody help us with some basic sample codes.?
Thanks in advance.

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/Socket.html

Similar Messages

  • Why no SecureSocket in web-based Flex?

    We are currently working on a web-based Flex (i.e. non-AIR) project that uses sockets to implement REST HTTP operations. We are required to encrypt all network traffic to and from the app, so I set off to fins a secure socket implementation. I came across the (supposedly) not-fully TLS-compliant ASCrypto project but then discovered the Flex 4 SecureSocket class. I nearly jumped up and down with joy and relief before realizing that it is tagged as "AIR-only".
    Can someone please tell me why this is? Our project would benefit greatly from a first-party implementation of a SecureSocket but we can't move to AIR.
    Thanks,
    Taylor
    P.S. Please feel free to suggest any other options that might exist for us to implement secure sockets in Flex.

    I really don't understand what you're saying. You use serialization when you want to send and receive an object's state over a stream. You use ObjectInputStream and ObjectOutputStream to read and write an object you're serializing.
    One common situation to use serialization in a web app is that if you make session variables serializable. If you do that, then a session can be shared among multiple servers, which have been set up for load balancing. At least that's how it works in WebSphere. I don't know if that's WS-specific or if it's a common way of doing it or even if it's maybe part of the spec.

  • Sockets in AS3

    Hi,
    I have a question about sockets in Flex. I tried connection to socket (FTP) and everything works just fine. But now I would like to open connection to socket and listen it. This socket does not exist. Basicly what I would like to do in creating server (in Flex app loaded in firefox browser - KIOSK Mode) that will allow software on computer (a software i've written) to communicate with flex app loaded in browser.
    Is that even possible? How can I do this?
    I have established connection via MozRepl and it works. But number of layers between does not make this the best way. So that's why I would like to do such stuff directly in Flex app and let software to connect to it.

    I have linux installed on a pc. On this linux box I have this software:
    - firefox -> loaded Flex api to display some data,
    - python script collecting data from CPU usage etc.
    I would like to open socket port on my Flex app so python script could also connect to my Flex simple server and send data to it. In my case CPU usage (some string value). This data would be recieved in Flex app and displayed in it. In my previous post I stated a solution with a MozRepl firefox extension.
    I'm asking you if it is posible to writer some HTTP server in Adobe flex so python sould post something to localhost:7755 (defined in Flex).
    Does Adobe Flex have capatabilies to run own HTTP server?
    Thnx in advance

  • Performance of Webservices

    i have a web services that returns the xml data, the size of
    the repose is 40% less if i used XML Attributes instead of XML
    Child Elements.
    Response format when i used child elements :
    <?xml version="1.0" encoding="utf-8"?>
    <ArrayOfEvent xmlns:xsi="
    http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="
    http://www.w3.org/2001/XMLSchema"
    xmlns="
    http://tempuri.org/">
    <Event>
    <dDate>1</dDate>
    <EventContent>test</EventContent>
    <CustName>test2</CustName>
    </Event>
    <Event>
    <dDate>2</dDate>
    <EventContent>test</EventContent>
    <CustName>test2</CustName>
    </Event>
    <ArrayOfEvent >
    Response format when i used properties:
    <?xml version="1.0" encoding="utf-8"?>
    <ArrayOfEvent xmlns:xsi="
    http://www.w3.org/2001/XMLSchema-instance"
    xmlns:xsd="
    http://www.w3.org/2001/XMLSchema"
    xmlns="
    http://tempuri.org/">
    <Event dDate="1" EventContent="test" CustName="test2"
    />
    <Event dDate="2" EventContent="test" CustName="test2"
    />
    <ArrayOfEvent >
    does flex parse the xml data faster if i used attributes over
    child elements?
    and also i wanted to know some expert comments,

    I'd imagine Flex (like most XML parsers) would parse the
    smaller file faster, since most of them simply read tokens from the
    stream as they arrive, so the less time it takes to arrive, the
    quicker it can be parsed into a message.
    As for the XML format, that's up to you. Typically my rule
    for attributes is that it should really be data used to identify or
    sort a tag, such as an ID, a timestamp or maybe a name. However,
    content typically should go inside the tag, or in a child-tag
    within it.
    So in your case I would probably put your event tag something
    like:
    <Event dDate="1" CustName="test2">test</Event>
    Or if you think you will have events later that might need
    more content parts:
    <Event dDate="1" CustName="test2">
    - <EventContent>test</EventContent>
    </Event>
    Both reduce the size a bit by using attributes but should
    hopefully remain neat enough to be useful. It's very much a case
    that XML isn't 100% strict on when to use attributes or child-tags,
    or rather, there are too many cases where it's unclear. So as I
    say, attributes are usually useful for identifying, sorting or
    specifying something important (type*). While actual data that
    won't be used for any of these goes in child-tags.
    * What I mean by 'type' is if you had property called
    "DataType" that defined the event as being one containing text, or
    an integer. Then this goes as an attribute since it determines the
    behaviour when reading the content.
    I hope that's useful, and hopefully some others will comment
    as well as I'm hardly an expert.
    As an additional note; if your requirements are ONLY
    performance, then (if you can) you may wish to consider a non-XML
    format. While XML is great for readability, and Flex has some great
    tools for working with raw XML strings, it is very wasteful (as
    you've seen), refer to the document for Sockets in Flex. However,
    they are much more complex to implement. As noted in another thread
    I'm trying to port a currently Java-based Binary XML format over to
    Flex, but I'm very much in research stages, it's a way off yet.
    However, it basically takes XML tags and turns them into short-hand
    forms that are quicker to send, and sends certain data-types as raw
    bytes. It's good as the difference in size due to attributes verus
    tags is non-existent. But yeah, gonna be a while till I complete it
    for Flex, and the Java one is not open-source as I may have to
    change the specification at any time.

  • Flex 3 Beta 2 Socket question

    Hi,
    Last night I spent about 3 hours looking for problem which
    came up for me yesterday. Before I'll get back to writing sample
    app which tell me if there is a problem in my code I will ask if
    anyone has noticed this behaviour.
    I'm connecting to c# socket with Socket class. First message
    goes nicely. But when I'm trying to write next messages nothing
    happends. Messages from socket are coming all the time. The problem
    is only with writing.
    I'm using writeUTFBytes method to write. RIght after writing
    I'm executing flush() n socket.
    Is it possible it is the problem with Flex Socket in 3 Beta
    2?

    in
    http://bugs.adobe.com/jira/browse/FB-9947
    it is remarked that re-establishing an internet connection resolves
    the issue, but it DOES NOT!
    I still get the
    'Flex Builder cannot access the server containing the Start
    Page content.
    If you are offline, try connecting to the network and
    refreshing the Start Page.' message.
    Andy

  • Problem with socket responses with flex

    Hi, I am using the code below to connect to an IMAP server.
    When I telnet to the server and use the commands that I am sending in the code, the rsponses are correct.
    However, when I run the code below, I only obtain the ready and logged in responses as shown below.
    Any ideas why I am not receiving the full set of responses from the socket?
    Thanks in advance fro your advice.
    The following is the output from the code:
    +++++++++++++++++ START SENDING IMAP DATA +++++++++++++++++++++++++
    sent: . login user1 myPassword
    sent: . status INBOX (messages)
    sent: . select INBOX
    +++++++++++++++++ END SENDING IMAP DATA +++++++++++++++++++++++++
    ++++++++ [IMAP START]
    Response is: * OK Dovecot ready.
    [IMAP END] +++++++++
    ++++++++ [IMAP START]
    Response is: . OK Logged in.
    [IMAP END] +++++++++
    The code is:
    <?xml version="1.0" encoding="utf-8"?>
    <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
       xmlns:s="library://ns.adobe.com/flex/spark"
       xmlns:mx="library://ns.adobe.com/flex/mx"
       applicationComplete="init()">
    <fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <fx:Script>
    <![CDATA[
    public var dataStr:String;
    private var socket:Socket;
    private var serverURL:String= "dead.org";
    private var serverPort:int = 143;
    private var serverResponse:ByteArray = new ByteArray();
    private function init():void
      this.serverURL = serverURL;
      this.serverPort = serverPort;
      socket = new Socket();
      socket.addEventListener(ProgressEvent.SOCKET_DATA,handleNewIMAPData); //Event when socket receives new data
      this.connectToServer();
      sendIMAPdata();
    private function sendString(dataStr:String):void
      var bytes:ByteArray = new ByteArray();
      bytes.writeMultiByte(dataStr, "UTF-8");
      socket.writeBytes(bytes);
      socket.flush();
      trace("sent: " + dataStr);
    public function sendIMAPdata():void
      trace("\t +++++++++++++++++ START SENDING IMAP DATA +++++++++++++++++++++++++");
      dataStr =". login user1 myPassword" + "\r\n";
      sendString(dataStr);
      dataStr =". status INBOX (messages)" + "\r\n";
      sendString(dataStr);
      dataStr =". select INBOX" + "\r\n";
          sendString(dataStr);
      trace("\t +++++++++++++++++ END SENDING IMAP DATA +++++++++++++++++++++++++");
    private function handleNewIMAPData(event:ProgressEvent):void
      var numBytes:int = socket.bytesAvailable;
      serverResponse = new ByteArray();
      while(socket.bytesAvailable)
        var byte:int = socket.readUnsignedByte();
    serverResponse.writeByte(byte);
      var response:String = serverResponse.toString();
      trace(" ++++++++ [IMAP START]\n Response is: " + response + "[IMAP END] +++++++++\n");
    private function connectToServer():void
      socket.connect(serverURL, serverPort);
    ]]>
    </fx:Script>
    </s:WindowedApplication>

    When I run telnet, the console responses are the same as the tcpdump messages.
    When I run the program, the messages from tcpdump match the messages in my trace statements.
    The messages from telnet and running the program are different:-)
    I can only assume (at the moment) that I am sending multiple messages too quickly(?), but I did a quick and dirty big "for loop" to slow down the sending of subsequent messages, but with no resulting change in the programs behaviour.
    So, still thinking about the problem -  unfortunately.

  • AS3.0 socket script doesn't work with flex coldfusion local server

    I am having a real problem using my script in flex coldfusion
    project. I tried everything I can to get an answer including
    posting a question in two groups with no success.
    I created a class that goes and connect through a socket
    connection and it works fine under “basic” flex
    project, however when I try to use the package in a flex coldfusion
    project I keep getting error messages:
    *** Security Sandbox Violation ***
    Connection to domainName.com:60 halted - not permitted from
    http://localhost:8500/ProjectName/bin/fileName.swf
    Error #2044: Unhandled SecurityErrorEvent:. text=Error #2048:
    Security sandbox violation:
    http://localhost:8500/ProjectName/bin/fileName.swf
    cannot load data from domainName.com:60. At
    com.elad.as3.socket::socketConnect$iinit()[C:\CFusionMX7\wwwroot\ProjectName\com\elad\as3 \socket\socketConnect.as:14]
    It looks to me that because there are two URL
    http://localhost:8500/ProjectName/bin/fileName.
    and
    C:\CFusionMX7\wwwroot\ProjectName\com\elad\as3\socket\socketConnect.as
    The player set the security in full effect and I cannot
    access other servers. I tried everything including setting the
    security and adding my local server to the approved servers.
    This is a real problem because I will not be able to test my
    application locally.
    Thanks in advance for the help,

    does anyone have any idea what could be going on here?  am i completely out to lunch?

  • Security error in flex,sockets

    Hi,
    I have a chat application in flex  using sockets.
    It works fine on Flash player 9, but while uisng flash player 10 , prompts the following  error
    Error: [SecurityErrorEvent type="securityError" bubbles=false cancelable=false eventPhase=2 text="Error #2048"]
    whats wrong?? iam  keep searching througth the web for a solution…  …Im using .Net framework 2.0 for socket server
    and flex 2

    Hi George,
    I'm pretty sure I know the cause of your security sandbox problem.
    In the move from Flash Player 9 to 10, Adobe increased the security constraints on sockets. As you might already know, when you use HTTP to connect to a server other than the one from which your SWF was downloaded, the Flash Player requires that a Cross-Domain Policy file be served up from the root of the target server. Prior to FP10, this constraint also existed for sockets as well, but since FP10 the requirement is more stringent: if you are using sockets to connect to an "un-trusted" server, then you will still need a Cross-Domain Policy file, however that policy file must also be served up through sockets.
    In other words, you will need to set up and run a socket server on the server you are connecting to, in order to serve up the appropriate XML document through port 843 (by default). This socket server can be implemented in any number of ways, but I use a Java socket server that Thomas over at LessRain has posted on their blog. You can find it here: http://www.blog.lessrain.com/as3-java-socket-connections-to-ports-below-1024/
    Good luck,
    Taylor
    4Point Solutions Ltd.
    http://blogs.4point.com/taylor.bastien/

  • Flex profiler: giving socket timeout error

    Hi,
    I am using Flex 3 Builder. With Flex 3 SDK and overlayed AIR 2 sdk. When I try profile my AIR app, I get "Socket Exception" in the console.
    I tried editing the mm.cfg manually but it seems not working. (Followed various posts in forums/blogs). But no Luck.
    I observed the mm.cfg file, keeping it blank, Flex Builder does write the PreloadSwf argument in it. For a while, and then it goes blank after throwing the socket error.
    I don't have Firewall on as well. I tried with both direct connection to internet and with Proxy.
    Any ideas on what's going on ?
    Thanks,
    Brijehs

    Tried all above, still getting the same exception

  • Configuring socket policy for flex apps(with blocked port 843)?

    We have built several flex-based ecommerce apps for a fortune 500 customer of ours, that for various reasons, we need to use sockets to a different domain and requires a socket policy file, but were having trouble configuring our flex apps for deployment in thier enviornment where they are blocking virtually everything except port 80 . The current documentation in in regards to socket policy files and crossdomain files in a non-standard configuration not using port 843 is not providing any useful help to us.
    Here is the scenario:
    Flex apps are served from domain www.a.com in  to users browsers via http. The apps then make socket connections to domain www.b.com:80 where there are php scripts serving json data to the flex apps via port 80 using http(we use sockets because we need to set and read back http headers). The problem is the flex apps cannot make socket connections to the www.b.com domain without errors like below(unless we setup a socket policy server on port 843 of www.b.com, in which case everything works):
    Warning: Timeout on xmlsocket://www.b.com:80 (at 3 seconds) while waiting for socket policy file.  This should not cause any problems, but see http://www.adobe.com/go/strict_policy_files for an explanation.
    Error: Request for resource at xmlsocket://www.b.com:80 by requestor from http://www.a.com/bin-debug/DownloadManagerFlex.swf is denied due to lack of policy file permissions.
    Error: Request for resource at xmlsocket://www.b.com:80 by requestor from http://www.a.com.us/bin-debug/DownloadManagerFlex.swf is denied due to lack of policy file permissions.
    Since we cannot use port  843 for the socket policy file server, we setup the socket policy server on a different ip in the same domain: spf.b.com:80 (using the sample perl code Adobe provides), and per the docs(cited below), use Security.loadPolicyFile("xmlsocket://spf.b.com:80") before we invoke "socket.connect", to supposedly tell the flash player to check there for the socket policy file. The problem, as you can see from the error log, is that the  loadPolicyFile("xmlsocket://spf.b.com:80") is ignored.
    No matter what we do or how we set things up, we cannot get the flash player to recognize the loadPolicyFile(), it always wants to go to the port were making the socket connection on. It is unclear how to properly configure the flex app, socket policy file and crossdomain file for the above scenario. The docs allude to being able to serve  the socket policy file from a different port 80 in the same domain as the socket connection were trying to make, but were having no luck with that.
    ->Can anyone shed some light on how to make this work or what are we  missing/doing wrong? Also, if we can get this to work, are we  stuck with a 3 second delay because this(very large) customer is blocking port 843?
    As an aside,  the documentation for all this is a bit scattered, unclear and contrdictory:
    One document says:(http://www.adobe.com/devnet/flashplayer/articles/fplayer9_security_07.html)
    "This warning usually means one of two things: first, that you need to set up a
                socket policy file server on port 843, which is the first location that Flash
                Player checks by default; or second, that you need to provide more explicit
                guidance to Flash Player from ActionScript by calling loadPolicyFile to indicate the location
                of a socket policy file. When you call loadPolicyFile rather than allowing Flash Player to check
                locations by default, Flash Player will wait as long as necessary for a
                response from a socket policy file server, rather than timing out after 3
                seconds."
    Another document says(http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html):
    "If an ActionScript Security.loadPolicyFile() command exists within               the SWF file, then the Flash Player runtime checks that location. Flash Player checks               the destination of the loadPolicyFile() only after it has checked the               master policy file on port 843 for permission to acknowledge other policy               files. If the developer has not specified a loadPolicyFile() command,               then Flash Player checks the destination port of the connection."

    I found the reason why the Flex application was ignoring the socket policy (crossdomain.XML). I have a policy server that listens to port 843 and submits the policy to the Flex client. My policy was getting ignored by the Flex application and I was getting the sandbox security error you were getting. The solution to this problem isto write a null byte right after the policy server sends the policy. I'm using Apache Mina that is wrtten is Java and the null byte is written as follows:
    public void sessionCreated (IoSession session)
            throws Exception
            session.write(_policy);  -- > policy string
            session.write("\u0000"); --> null byte
             //session.close(true); ---> No need to close the session because it is closed by the Flex client after it receives the null byte.
    Now my Flex application can read and accept the policy from port 843 and I'm not getting more security violations.
    Thanks for your reply,
    Alberto

  • Socket Time out while running Flex Profiler .

    Hi ,
    I have  develped a sample Flex Application , whne i am trying to run the Profile Application with in the Flex Builder ,
    I am getting Socket Time Out .
    Can anybody please let me know how to resolve this exception .
    Thanks in advance .

    Reboot and try again.  Sometimes some player instance in a browser or IM
    hangs up the socket.

  • Flex Socket not working in Android Gingerbread

    Hi,
    I am having this mobile application where it will connect to Air ServerSocket deployed in desktop machine. The problem is socket connection is not working in my device running Android 2.3.5 while it id working on the other device running 4.2.2. Please help.
    Best regard,
    Victor

    do your IE has installed flashplayer plun-in? if so, is plug-in enabled?

  • Flex mobile socket connection error

    ReferenceError: Error #1069: Property shareable not found on flash.utils.ByteArray and there is no default value.
    any one who knows this problem, wating for help

    Remove the isConnected() test and associated code: it's contributing nothing here. If the socket itself throws an exception then you have a problem. At the moment all you have is a self-inflicted wound.
    You can also remove the bind(null) call.

  • Flex (AS3) + Node.js + Socket.IO text chat

    There is a very promising technology useful for creating online multiplayer games. I'm trying to do a chat on this example https://github.com/simb/FlashSocket.IO.
    Server is created, the data on a server received (see the console log), but these other chat users are not received messages, broadcast messages are not working.
    If anyone has the desire, please test this example - you want installed node.js and module Socket.IO.
    Console log:
    C:\inetpub\wwwroot\3>node app.js
       info  - socket.io started
    Socket-Chat listening on port 9202.. Go to http://<this-host>:9202
       debug - client authorized
       info  - handshake authorized 3088178251169496669
       debug - setting request GET /socket.io/1/flashsocket/3088178251169496669
       debug - set heartbeat interval for client 3088178251169496669
       debug - client authorized for
       debug - websocket writing 1::
       debug - websocket received data packet 3:::USERNAME: cvx
       debug - websocket received data packet 3:::xcvcx

    hi Soctt,
    Would you like to make sense Azure mobile service? Please see this tutorials:
    http://azure.microsoft.com/en-us/documentation/articles/mobile-services-javascript-backend-phonegap-get-started/
    Regards,
    Will
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • If I copy the "lcds" folder, Tomcat starts with socket errors

    In the documentation it is said that when you create a new server-side application, you can start by copying the 'webapps/lcds' folder. I did that but then, Tomcat starts with some socket errors:
    [LCDS]SocketServer 'my-rtmp-SocketServer' failed to pre-validate desired socket settings for BindSocketAddress: 0.0.0.0:2038
    java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind
    [LCDS]SocketServer 'my-rtmp-SocketServer' failed to start.
    flex.messaging.LocalizedException: SocketServer 'my-rtmp-SocketServer' cannot bind to accept client connections on port '2038' because another process has already bound the port. Please ensure that multiple endpoints across all applications  are not configured to use this same port.
    Am I doing something wrong?
    Thanks,
    Borek

    What is happening is that you are getting a port conflict for the socket-based NIO and RTMP endpoints used in the channel definitions in the services-config.xml file of your new web app. The issue is that you have endpoints bound to the same port  in the LCDS web and in your new web app.
    You can deal with this one of two ways:
    Option 1: In that services-config.xml file, search on "RTMP" and "NIO" to find the channel definitions and change the port numbers to something slightly different than the ones used in the LCDS web app.
    Options 2: Move the LCDS web app out of the picture so it doesn't get loaded, and just use a template for future web apps. If you aren't using it for any of your development, there is really no reason you have to load it.
    I'll add a note about this to the documentation that talks about using the LCDS web app as a template.

Maybe you are looking for

  • Saving a PDF or DOC file into Oracle 9i using Developer Forms 10g

    Hi guys, I want to save a pdf or doc file into oracle 9i. I am using Developer 10 g. Please help me; 1. What datatype field should be in database table to store such file. 2. Which code should I use in Forms 10g to display open file dialog, get the n

  • Vendor Master Create with reference

    Hello We have a sizable number of vendors that need to be created in a 45 new company codes. These vendors already exist in other company codes. What is the easiest way - to create these vendors in these new company codes with reference to one of the

  • F  *** ERROR = Node 'bootstrap' failed with exit code 503.

    Hi,      i installed the sap nw 7.2 trial version succesfully and due to sapgui problem i downloaded a new sapgui 720 patches from the service place and installed and when installation ,i installed jre for the sapgui. after that when i start the sap

  • Engent, Who could help about selection-screen.

    Below is the code!   CALL FUNCTION 'DATE_CREATE'     EXPORTING       anzahl_tage = 7       datum_ein   = sy-datum     "     IMPORTING       datum_aus   = gdf_wadat.   " SELECT-OPTIONS: p_wadat  FOR likp-wadat DEFAULT sy-datum to gdf_wadat. All I want

  • Question OTL Timecard (Auto-Approval).

    Hi All, I'm facing a problem while uploading the time via OTL API's. I'm using below OTL API's to upload the time. 1.hxc_timestore_deposit.create_timecard_bb 2.hxc_timestore_deposit.create_day_bb 3.hxc_timestore_deposit.create_detail_bb 4.hxc_timesto