Copy link to clipboard
Copied
hi,
when I upload an apk to my Desire Z, with INTERNET manifest permissions added, I cannot bind a socket to its local network,
or connect it to a remote computer, because of an invalid socket eror:
Error #2002: Operation attempted on invalid socket.
I'm using air 2.5 and android 2.2. Also,
Also, should the findInterfaces method not return at least one interface? It returns 0.
public class UDPClient
{
protected var _datagramSocket: DatagramSocket = new DatagramSocket()
public function UDPClient( )
{
findInterface();
init();
}
public function findInterface():void {
var results:Vector.<NetworkInterface> = NetworkInfo.networkInfo.findInterfaces();
trace( "l: " + results.length );//RETURNS 0
}
protected function init():void
{
if( _datagramSocket.bound )
{
_datagramSocket.close();
_datagramSocket = new DatagramSocket();
}
FAILS TO BIND OR CONNECT:
_datagramSocket.bind( 33445, "127.0.0.1");//INVALID SOCKET ERROR
// _datagramSocket.bind( 33445, "0.0.0.0");//INVALID SOCKET ERROR
//_datagramSocket.connect( "77.250.160.80", 33443);//INVALID SOCKET ERROR
_datagramSocket.addEventListener(DatagramSocketDataEvent.DATA, dataHandler)
_datagramSocket.addEventListener(IOErrorEvent.IO_ERROR, IOErrorHandler);
_datagramSocket.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
_datagramSocket.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
_datagramSocket.receive();
}
Copy link to clipboard
Copied
The Datagram socket class is not currently supported on mobile. (See http://help.adobe.com/en_US/air/build/WS144092a96ffef7cc16ddeea2126bb46b82f-8000.html)
Also note that you must add the following permissions to use the NetworkInfo class on Android:
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
Copy link to clipboard
Copied
Seriously, what's up with that. Can't create ServerSocket, Can't create DatagramSocket. No NetworkInfo. There's so many possibilities with those on the mobie platform and we can't have any of it.
Copy link to clipboard
Copied
thanks Joe.
So does this mean that we can't use UDP at all to send and receive messages with air for android to and from remote computers?
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more