1 Reply Latest reply: May 2, 2012 10:06 AM by sinious RSS

    iOS Sockets: Error #2002: Operation attempted on invalid socket.

    ScottTompkins Community Member

      Hey All,

       

      If anyone has a fix for this it would be greatly appreciated, or just let me know if I'm missing something, but I can't seem to get a port open while running on iOS. I've read a lot of reasons for this is that the port is still in-use from a previous session of the application that failed to close the port properly, but that is simply not there case here. To test this, I've tried looping through a variety of different port ranges on application start, and this error occurs on every port attempted...

       

      import flash.net.ServerSocket;

      import flash.net.Socket;

      ...

       

      for (var port:Number = 1000; port <=1020; port++){

          var serverSocket:ServerSocket = new ServerSocket();

          serverSocket.addEventListener(Event.CONNECT, socketConnectHandler);

          serverSocket.bind(port);

          serverSocket.listen();   

      }

       

      it breaks every time on serverSocket.bind(port) with "Error #2002: Operation attempted on invalid socket.";

       

      Any help would be greatly appreciated. Also, I'm using Flash Builder 4.6 compiling to Flex 4.6.0 SDK.

       

      Thanks!