【问题标题】:How can I receive data packets in GPRS in my android mobile?如何在我的安卓手机中接收 GPRS 数据包?
【发布时间】:2012-04-16 04:22:15
【问题描述】:

我需要使用我的 android 手机接收从 GSM 调制解调器通过 GPRS 发送的数据包... 谁能帮我发送和接收.. 必须使用什么协议?

【问题讨论】:

    标签: android android-intent gsm gprs


    【解决方案1】:

    在服务器启动中创建一个线程并执行以下操作

    ServerSocket serverSocket = new ServerSocket(8000); //8000 - port number
    Socket client = serverSocket.accept();  // thread will wait here till a client connects
    
    BufferedReader inFromClient = new BufferedReader(
                            new InputStreamReader(client.getInputStream()));
                    DataOutputStream outToClient = new DataOutputStream(
                            client.getOutputStream());
    while ((inputLine = inFromClient.readLine()) != null) {   
                        System.out.println("Server: " + inputLine);
    
                        if(inputLine.equals("END"))
                        {
                            outToClient.writeBytes("END\n");
                        }
                        else
                        {
                            outToClient.writeBytes("Received\n");
                        }
                    }
                    inFromClient.close();
                    outToClient.close();
    

    这是你需要处理的 TCP 连接

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-23
      • 1970-01-01
      • 1970-01-01
      • 2017-07-14
      • 1970-01-01
      相关资源
      最近更新 更多