title: Java Out Of Band (called "urgent data") data
body: <p>Here is some elementary code trying to use OOB (Urgent) data. My problem is that the server part don't behave the same if the client is in C or in Java.
  Becareful, you may think that something's tricky in both client side but if I use a C server (to get finer control of OOB), then both clients behave exactly the same whatever is my server-side OOB control.</p>
  
  <p>First the server (Java) part :</p>
  
  <pre><code>Socket s = ss.accept();
  s.shutdownOutput();
  s.setOOBInline(true);
  InputStream is = s.getInputStream();
  for (;;) {
    byte []d = new byte[3];
    int l = is.read(d);
    if (l==-1) break;
    for (int i=0; i&lt;l; i++) System.out.print((char)d[i]);
    System.out.println();
    Thread.sleep(2000);
  }
  </code></pre>
  
  <p>Then the client (Java) part :</p>
  
  <pre><code>Socket s = new Socket("localhost",61234);
  s.shutdownInput();
  OutputStream os = s.getOutputStream();
  byte []n = new byte[10];
  for (int i=0; i&lt;n.length; i++) n[i] = (byte)('A'+i);
  byte m = (byte)('0');   
  os.write(n);
  System.out.println("normal sent");
  s.sendUrgentData(m);
  System.out.println("OOB sent");
  os.write('Z');
  System.out.println("normal sent");
  </code></pre>
  
  <p>and then the alternate client (C) part :</p>
  
  <pre><code>s = socket(PF_INET,SOCK_STREAM,0);
  bzero(&amp;a,sizeof(a));
  a.sin_family = AF_INET;
  a.sin_port = htons(61234);
  a.sin_addr.s_addr = inet_addr("127.0.0.1");
  connect(s,(struct sockaddr *)&amp;a,sizeof(a));
  shutdown(s,SHUT_RD);
  char m = '0';
  char *n = "ABCDEFGHIJ";
  
  printf("normal sent %d\n",write(s,n,strlen(n)));
  printf("OOB sent %d\n",send(s,&amp;m,1,MSG_OOB));
  printf("normal sent %d\n",write(s,"Z",1));
  </code></pre>
  
  <p>Now this is what I get (first C client, then Java client) :</p>
  
  <pre><code>Accepting connection
  ABC
  DEF
  GHI
  J
  Z
  Accepting connection
  ABC
  DEF
  GHI
  J
  0Z
  </code></pre>
  
  <p>It seems that the Java server isn't able to see the OOB data sent from C-client-side. Why the <code>0</code> seems to have been lost ? It has not, because the server have at least detected the oob boundary in the stream. </p>