1

I need to receive data packets send from a GSM modem through GPRS with my android mobile... Can any one help me how to send and receive.. What protocol has to be used?

4

1 に答える 1

2

サーバーの起動時にスレッドを作成し、次の操作を行います

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接続

于 2012-05-30T10:55:52.107 に答える