Skip to main content
Participant
December 16, 2010
Question

How to enable socket connection?

  • December 16, 2010
  • 1 reply
  • 1590 views

I have allowed INTERNET permission, but my socket still blocked.

     <uses-permission android:name="android.permission.INTERNET" />

If I compile apk with -debug tag, then socket connection works, but my application runs very slow.

And I dont want to publish a release version with all my debug messages.

What is the standard way to open socket connection?

Thanks

This topic has been closed for replies.

1 reply

EasonPaiAuthor
Participant
December 21, 2010

Anybody?

Need help~

Participating Frequently
December 23, 2010

               var s:Socket=new Socket();

                s.connect("ip_address", "port_number");

                s.addEventListener(Event.CONNECT, function(event:Event):void{

                    trace('connected!');

                });

                s.addEventListener(IOErrorEvent.IO_ERROR, function(event:IOErrorEvent):void{

                    trace('error! ' + event.errorID);

                });

                s.addEventListener(ProgressEvent.SOCKET_DATA, function(event:ProgressEvent):void{

                    var str:String=(event.currentTarget as Socket).readUTF();

                });

There are examples out there.  Fire up Google Search .

Participating Frequently
December 23, 2010

Make sure ip address and port numbers match.  Also, make sure ServerSocket or the listening end is allowing traffic in and out (ip adn port must match).