3 Replies Latest reply: Jan 5, 2009 9:37 AM by 843851 RSS

    Send & receive data over GPRS

    843851
      Hi All !!!
      I am developing a program to receive and send data over GPRS. A remote device is sending data at a particular port (6600) of my server. I am able to read that through ServerSocket. However I am not being able to send any data to that device.

      Any help?
        • 1. Re: Send & receive data over GPRS
          843851
          I am using the code:
          // Constructor
          public ServerSocketReader(Socket socket) {
          super("MultiSocketThread");
          this.clientSocket = socket;
          this.setDaemon(true);
          }

          public void run() {

          try {
          OutputStream out = clientSocket.getOutputStream();
          InputStreamReader in = new InputStreamReader(clientSocket.getInputStream ());
          //BufferedWriter bw = new BufferedWriter(new FileWriter(_filepath, true));
          java.util.Date date = new java.util.Date();
          SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd-MMM-yy HH:mm:ss");
          GprsProtocol protocol = new GprsProtocol();

          int charCount = 0;
          char[] cBuffer = new char[1000];
          byte[] bBuffer;
          String fromClient = "", toClient = "START";

          int ii = 0;
          while ((ii = in.read()) != -1) {
          fromClient = fromClient + (char)ii;
          if (fromClient.endsWith("2Y")) { //according to protocol
          toClient = protocol.processInput(fromClient); //Protocol
          bBuffer = toClient.getBytes();
          for (int k=0; k<bBuffer.length; k++) {
          out.write ((char)bBuffer[k]);
          out.flush();
          }
          fromClient = "";
          }
          }

          out.close ();
          in.close ();
          clientSocket.close ();
          //bw.close();

          } catch (IOException ioe) {
          //out.println("Error::" + e);
          System.out.println("Error in writing file : ");
          ioe.printStackTrace();
          } catch (Exception e) {
          System.out.println("Error in ServerSocketReader : ");
          e.printStackTrace();
          }
          finally {
          //this.destroy();
          }
          }
          I am geeting the error at line :-
          while ((ii = in.read()) != -1) {

          the error is :-
          java.net.SocketException: A connection with a remote socket was reset by that socket.: A connection with a remote socket was rese
          by that socket.
          at java.net.SocketInputStream.socketRead(Native Method)
          at java.net.SocketInputStream.read(SocketInputStream.java:104)
          at java.net.SocketInputStream.read(SocketInputStream.java:82)
          at java.io.InputStreamReader.fill(InputStreamReader.java(Compiled Code))
          at java.io.InputStreamReader.read(InputStreamReader.java:256)
          at java.io.InputStreamReader.read(InputStreamReader.java:229)
          at ServerSocketReader.run(ServerSocketReader.java(Compiled Code))
          • 2. Re: Send & receive data over GPRS
            843851
            Hi !!!
            No hint for the above problem?
            • 3. Re: Send & receive data over GPRS
              843851
              Can I know which server you are using for that ???