import java.io.*;
import java.net.*;
import java.util.*;
+import java.util.concurrent.Semaphore;
// FIXME: accept connections, but stall, during programming
public class Server {
final OutputStream fos = sp.getOutputStream();
final InputStream fis = new BufferedInputStream(sp.getInputStream());
+ final Semaphore sem = new Semaphore(15);
+
System.err.println("sending instructions...");
new Thread() {
public void run() {
while(true) {
int r = is.read();
if (r == -1) break;
- fos.write(r);
+ synchronized(fos) {
+ fos.write(r);
+ }
}
fos.flush();
} catch (Exception e) { throw new RuntimeException(e);
if (closed) { os.flush(); return; }
val = fis.read();
if (val==-1) break;
+ if ((val & (1<<6)) == 0) {
+ synchronized(fos) {
+ fos.write( (1<<6) | 1);
+ }
+ }
System.err.println("byte: 0x"+Integer.toString(val & 0xff, 16));
os.write((byte)val);
result |= ((long)val) << (i * 8);