title: Error in making a socket connection
body: <p>I am trying to run the program below, but I am getting this error:</p>
  
  <pre><code>Exception in thread "main" java.net.ConnectException: Connection refused: connect
      at java.net.PlainSocketImpl.socketConnect(Native Method)
      at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
      at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
      at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
      at java.net.Socket.connect(Socket.java:529)
      at com.rabbitmq.client.ConnectionFactory.createFrameHandler(ConnectionFactory.java:445)
      at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:504)
      at com.rabbitmq.client.ConnectionFactory.newConnection(ConnectionFactory.java:533)
      at Recieve.main(Recieve.java:14)
  </code></pre>
  
  <p>The program I am trying to run is:</p>
  
  <pre><code>import com.rabbitmq.client.Channel;
  import com.rabbitmq.client.Connection;
  import com.rabbitmq.client.ConnectionFactory;
  
  public class Send {
      private final static String QUEUE_NAME = "hello";
  
      public static void main(String[] argv) throws java.io.IOException {
          ConnectionFactory factory = new ConnectionFactory();
          factory.setHost("localhost");
          Connection connection = factory.newConnection();
          Channel channel = connection.createChannel();
          channel.queueDeclare(QUEUE_NAME, false, false, false, null);
          String message = "Hello World!";
          channel.basicPublish("", QUEUE_NAME, null, message.getBytes());
          System.out.println(" [x] Sent '" + message + "'");
          channel.close();
          connection.close();
      }
  }
  </code></pre>
  
  <p>I am not aware of making a socket connection, please let me know how to resolve this.</p>