public void run() {
		
			while (!Thread.interrupted()) {
				try {
				Socket sin = waitForData();
				String filename = sin.getInetAddress().getHostAddress() + "_" + new SimpleDateFormat("yyMMdd_HHmmss").format(new Date()) + ".gcode";
				InputStream in = sin.getInputStream();
				
				BufferedOutputStream bufout = new BufferedOutputStream(sin.getOutputStream());
//				bufout.write(1); //version 
//				bufout.flush();
				
				BufferedInputStream bufin = new BufferedInputStream(in);
				bufin.mark(4);
				byte[] magic = new byte[3];
				int len = bufin.read(magic);
				// Magic is 0x3B 0xC0 0xDE - (3B=; to be handled as comment by
				// older versions)
				if (len == 3 && magic[0] == (byte)0x3B && magic[1] == (byte)0xC0 && magic[2] == (byte)0xDE) {
					parseCommandHeader(filename, bufin,bufout);
				} else {
					//old version path
					bufin.reset(); //3bytes are not the magic.. reset to pos 0
					gp.printreceived(filename, bufin, false, false,0);
				}
				sin.close();
		
				} catch (IOException e) {
					e.printStackTrace();
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
	}