10 Replies Latest reply: Feb 19, 2007 12:40 AM by 807597 RSS

    I want to receive and send data in ASCII how can I do? (Have the code)

    807597
      I use my program connect to server (the server is .exe file) after I connect in ms-dos mode I want to send the command from client to server but nothing is happen such as I want to send MOVE 50 it means move 50cm nothing is back(may be because I haven't convert it to ASCII first) How can I change mycode to read and wrtie ASCII code?

      public class proxy_server {
         
          /** Creates a new instance of proxy_server */
          public static void main(String args[]) throws IOException {
                  Socket sock=null;
                  PrintWriter out=null;
                  BufferedReader in=null;
                  sock = new Socket("localhost", 3000);
                  out=new PrintWriter(sock.getOutputStream(),true);
                  in=new BufferedReader(new InputStreamReader(sock.getInputStream()));
             
                  BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
                  String userInput;
                  while(( stdIn.readLine()!=null)){
                      userInput=stdIn.readLine();
                      out.println(userInput);
                      System.out.println("echo"+in.readLine());
                  }
                  out.close();
                  in.close();
                  stdIn.close();
                  sock.close();
              
          }    
      }