title: How to send byte array to socket using ZeroMQ?
body: <p>I am working with ZeroMQ for the first time and I wrote a simple utility to send the data to sockets. Below is my simple class by which I am sending data to sockets using ZeroMQ. As of now I am playing with ZeroMQ so wrote a simple class as shown below and after I get more familiar then I need to put the same code in multithreading code.</p>
  
  <pre><code>public static void main(String[] args) {
  
      ZMQ.Context context = ZMQ.context(1);
  
      // as of now sending only 10 data
      for (int i = 1; i &lt;= 10; i++) {
          ZMQ.Socket socket = context.socket(ZMQ.PUSH);
          socket.connect("tcp://localhost:10000");
  
          byte[] packByteArray = generateRandomStringAsBytes();
  
          ZMsg req = new ZMsg();
          req.add(packByteArray);
          req.send(socket);
  
          socket.close();
      }
      context.term();
  }
  </code></pre>
  
  <p>Since this is my first time so I don't know whether this is the right and efficient way of using ZeroMQ to send the data as byte array? I have heard of various thing like ZFrame and ZMsg, not sure when do we need to use both and what is the best way of sending byte array to a socket.</p>
  
  <p>In our case, we need to send random string as the bytes to the socket so not sure what is the best and efficient way of using ZeroMQ?</p>