4 Replies Latest reply on Nov 10, 2006 12:13 PM by ensamblador

    Socket comunication.

    ensamblador Level 1
      I recently discover the XMLSocket Object in flash. I think is the simplest solution for to develop socket comm, is clean, free, safe for shockwave (it comes with the flash xtra) but it has several problems. It can not stay in listen mode, it can not connect to ports lower than 1024, among others.

      So i´ve decide to implement an xtra that can listen in a specific port and can attend multiple clients, with this xtra i could easily develop a socket server than can respond and coordinate querys from clients (XMLSockets).

      Before start coding (i always try to evade coding xtras), anyone knows a free third-party solution? (socket xtra).



        • 1. Re: Socket comunication.
          the real POTMO Level 1
          it can stay in listenmode and it can connect on ports lower than 1024
          http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context= LiveDocs_Parts&file=00001623.html
          so use flashsockets.
          • 2. Re: Socket comunication.
            ensamblador Level 1
            Thank you for reply.

            I readed the flash documentation for XMLSocket and in fact you can download a policy file that tweaks a little the security restrictions.

            For to comunicate to ports lower than 1024 you need to call System.security.loadPolicyFile(), you know a method to call this function from Lingo?

            Another thing is the listen mode (socket server), i re-readed the page and didn´t find this part.

            • 3. Re: Socket comunication.
              the real POTMO Level 1
              This is a framscript that we used to test socket communication.
              Our socket server replied everything you sent to it.


              global gSock
              property pStartTime, pPings, pState

              on beginSprite me

              member("debug").text = RETURN & "Starting..." & RETURN

              me.debug("Getting policyfile")
              newObject("System.security.loadPolicyFile", "xmlsocket://192.168.1.108:80")

              me.debug("creating socket")
              gSock = newObject("XMLSocket","")

              me.debug("Connecting to socket")
              gSock.connect("192.168.1.108",80)

              setCallback(gSock, "onConnect", #onConnect, me)
              setCallback(gSock, "onData", #onData, me)
              setCallback(gSock, "onClose", #onClose, me)

              pState = #wait

              end

              on onConnect me, tSock, tOk
              me.debug("Connected to socket")

              me.debug("Sending first PING")

              pStartTime = the milliseconds

              pState =#sending

              end

              on onData me, tSock, tMsg


              tMsg = value(tMsg)
              sprite("p1").locH = sprite("p1").locH + 1
              sprite("p2").locH = sprite("p2").locH + 1

              pState = #sending

              end

              on onClose me, tSock
              me.debug("Socket Closed")
              end

              on endSprite me
              gSock.close()
              end

              on exitFrame me

              case pState of
              #sending:
              gSock.send(string([#p1:"WALK"]))
              gSock.send(string([#p2:"WALK"]))
              pState =#wait
              #wait:

              end case


              sprite("p3").locH = sprite("p3").locH + 1
              go to the frame
              end

              on debug me, txt
              put TAB & txt & RETURN after member("debug")
              end





              When you have opened a socket you can send data from both directions.
              The tricky part is that youll have to write a server app that will reply the policyfile over socket.

              /POTMO
              • 4. Re: Socket comunication.
                ensamblador Level 1
                Thanks a lot,

                No doubt that the way for load the policy file will help to re-define interdomain and ports restrictions. You help me a lot.

                Another thing is the listen mode. I mean a socket server, which cannot be implemented with XMLSocket. A discover several XMLSocket server xtras. So i believe is not that simple to implement with XMLSocket objects.

                Fortunately, i recently compiled a win32 app, which listen in the specific port of the machine and accepts connections from clients (that already know the IP:port of the service). I tested with a demo app developed with XMLSocket and works fine.

                the next step is to port the app to a xtra, define some apis, and will ready to program an aplication server.