Ejemplo n.º 1
0
        /// <summary>
        /// Tries to connect to the server.
        /// Returns if it was successfull.
        /// </summary>
        private void TryConnect()
        {
            try
            {
                int attempts = 0;
                while (!LocalSocket.Connected)
                {
                    try
                    {
                        Debug("Connection attempt " + attempts++, DebugType.Warning);
                        LocalSocket.Connect(serverIP, port);
                    }
                    catch (SocketException) { }
                }

                Debug($"Connection successfull! Required {attempts} attempts", DebugType.Info);
            }
            catch (Exception ex)
            {
                Debug("Halting (13)", DebugType.Warning);
                if (ShowExceptions)
                {
                    Debug($"({ex.GetType().Name}) {ex.Message}", DebugType.Exception);
                }
                if (AutoRestartOnCrash)
                {
                    HaltAllThreads();
                }
            }
        }
Ejemplo n.º 2
0
        protected void createSockets()
        {
            if (sPipeApi == PIPE_API_LS)
            {
                const String LOCAL_ADDR = "net.majorkernelpanic.streaming-";

                for (int i = 0; i < 10; i++)
                {
                    try {
                        mSocketId = new Java.Util.Random().NextInt();
                        mLss      = new LocalServerSocket(LOCAL_ADDR + mSocketId);
                        break;
                    } catch (Java.IO.IOException e1) {}
                }

                mReceiver = new LocalSocket();
                mReceiver.Connect(new LocalSocketAddress(LOCAL_ADDR + mSocketId));
                mReceiver.ReceiveBufferSize = 500000;
                mReceiver.SoTimeout         = 3000;
                mSender = mLss.Accept();
                mSender.SendBufferSize = 500000;
            }
            else
            {
                Log.e(TAG, "parcelFileDescriptors createPipe version = Lollipop");
                mParcelFileDescriptors = ParcelFileDescriptor.CreatePipe();
                mParcelRead            = new ParcelFileDescriptor(mParcelFileDescriptors[0]);
                mParcelWrite           = new ParcelFileDescriptor(mParcelFileDescriptors[1]);
            }
        }
Ejemplo n.º 3
0
 private void CreateSockets()
 {
     receiver           = new LocalSocket();
     localSocketAddress = new LocalSocketAddress("localServer" + socketId);
     receiver.Connect(localSocketAddress);
     receiver.ReceiveBufferSize = 500000;
     receiver.SendBufferSize    = 500000;
     sender = lss.Accept();
     sender.ReceiveBufferSize = 500000;
     sender.SendBufferSize    = 500000;
 }
Ejemplo n.º 4
0
            public static bool SendFd(string sockPath, Java.IO.FileDescriptor fd)
            {
                var socket = new LocalSocket();

                try {
                    socket.Connect(new LocalSocketAddress(sockPath, LocalSocketAddress.Namespace.Filesystem));
                    socket.SetFileDescriptorsForSend(new Java.IO.FileDescriptor[] { fd });
                    socket.OutputStream.Write(new byte[] { 42 });
                } catch (Exception e) {
                    Logging.warning("sendfd: " + e.Message);
                    return(false);
                } finally {
                    socket.Close();
                }
                return(true);
            }
		private void CreateSockets(){
			receiver = new LocalSocket();
			localSocketAddress = new LocalSocketAddress("localServer"+socketId);
			receiver.Connect(localSocketAddress);
			receiver.ReceiveBufferSize = 500000;
			receiver.SendBufferSize = 500000;
			sender = lss.Accept();
			sender.ReceiveBufferSize = 500000;
			sender.SendBufferSize = 500000;
		}