title: Jeromq maximum socket opened issue
body: <p>I have a <code>server</code> in java which receive a <code>json</code> file and send it to a C program by <code>jeromq</code>. Until last week I just tested it with a few json. I haven't sent a lot of json until now I have another component to send them.</p>
  
  <p><code>Glassfish</code> hanged with an error I have never seen before. Something like:</p>
  
  <pre><code>[2014-08-19T09:24:32.446+0000] [glassfish 4.0] [WARNING] [] [java.util.prefs] [tid: _ThreadID=141 _ThreadName=Timer-1] [timeMillis: 1408440272446] [levelValue: 900] [[
  Could not lock User prefs.  Unix error code 24.]]
  
  [2014-08-19T09:24:32.446+0000] [glassfish 4.0] [WARNING] [] [java.util.prefs] [tid: _ThreadID=141 _ThreadName=Timer-1] [timeMillis: 1408440272446] [levelValue: 900] [[
    Couldn't flush user prefs: java.util.prefs.BackingStoreException: Couldn't get file lock.]]
  </code></pre>
  
  <p>And something related to ZMQ:</p>
  
  <pre><code>[2014-08-15T08:23:30.637+0000] [glassfish 4.0] [SEVERE] [] [] [tid: _ThreadID=2432     _ThreadName=Thread-4] [timeMillis: 140809101063$
    zmq.ZError$IOException: java.io.IOException: Too many open files
      at zmq.Signaler.make_fdpair(Signaler.java:87)
      at zmq.Signaler.&lt;init&gt;(Signaler.java:48)
      at zmq.Mailbox.&lt;init&gt;(Mailbox.java:55)
      at zmq.Ctx.&lt;init&gt;(Ctx.java:127)
      at zmq.ZMQ.zmq_ctx_new(ZMQ.java:225)
      at zmq.ZMQ.zmq_init(ZMQ.java:258)
      at org.jeromq.ZMQ$Context.&lt;init&gt;(ZMQ.java:173)
      at org.jeromq.ZMQ.context(ZMQ.java:155)
  
      ...
  
      at java.lang.Thread.run(Thread.java:744)
  Caused by: java.io.IOException: Too many open files
      at sun.nio.ch.IOUtil.makePipe(Native Method)
      at sun.nio.ch.PipeImpl.&lt;init&gt;(PipeImpl.java:42)
      at sun.nio.ch.SelectorProviderImpl.openPipe(SelectorProviderImpl.java:50)
      at java.nio.channels.Pipe.open(Pipe.java:150)
      at zmq.Signaler.make_fdpair(Signaler.java:85)
      ... 11 more]] 
  </code></pre>
  
  <p>I think it could be related to something worng with zmq. If server just receive a few json it never hangs.</p>
  
  <p>I paste my java code, maybe I am doing something wrong or I am not closing something:</p>
  
  <p>First I create a thread to make the zmq sent:</p>
  
  <pre><code>new Thread(new SubmitJSONOnBackground(json, this.context)).start();
  </code></pre>
  
  <p>My class to run in background: </p>
  
  <pre><code>public class SubmitJSONOnBackground implements Runnable {
  private Collection&lt;JSON&gt; jsons;
  private ServletContext context;
  public SubmitObservationOnBackground(Collection&lt;JSON&gt; json, ServletContext context) {
      this.jsons = json;
      this.context = context;
  }
  public void run() {
      SubmitJSONHandler submit = new SubmitJSONHandler(jsons, this.context);
      submit.buildAndSubmitJSON();
  }
  </code></pre>
  
  <p>}</p>
  
  <p>And the method which sends zmq: </p>
  
  <pre><code>private boolean submitJSON(String message) {
      ZMQ.Context context = ZMQ.context(1);
      ZMQ.Socket sender = context.socket(ZMQ.PUSH);
      sender.connect("tcp://127.0.0.1:9999");
      sender.send(device, ZMQ.SNDMORE);
      sender.send("json", ZMQ.SNDMORE);
      sender.send("["+message+"]", 0);
      sender.close();
      context.term(); 
      return true;
  }
  </code></pre>
  
  <p>I think it is ok, but since it is failing something related to <code>ZMQ</code> I am not sure it is ok or not.</p>