0

I am new to Java socket programming and I am trying to connect to a Server running in Tandem/NonStop using a Java socket program. The connection is getting refused. Below is my Java program:

try {           
    Socket clientSocket = new Socket();
    clientSocket.setKeepAlive(true);
    clientSocket.setReuseAddress(true);
    clientSocket.setTcpNoDelay(true);
    clientSocket.setSoTimeout(120000); 
    clientSocket.setSendBufferSize(65535);
    clientSocket.connect(new InetSocketAddress(serverAddress, serverPort), 10000);

    OutputStream outstream = clientSocket.getOutputStream(); 
    outstream.flush();
    outstream.close();
    clientSocket.close();
    } catch (Exception e) {
    e.printStackTrace();
    }   

below is the error stack trace:

java.net.ConnectException: Connection refused: connect
    at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
    at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
    at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
    at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.net.Socket.connect(Socket.java:589)
    at com.connect.socket.TestConnection.main(TestConnection.java:23)

Note - For the Server running in Tandem/NonStop, I am running the sample C TCP Server Program present in HPE NonStop TCP/IP Programming Mannual.

I need some help to connect my java client program to the server running in Tandem/NonStop.

Ajitav Dutta
  • 99
  • 1
  • 11
  • I don't work on a Tandem but my wife does. For what it's worth a connection refused error usually means the server is not listening on that port. Did you compile the server program yourself and if so, what port is it listening on? Have you tried doing a traceroute to verify that there are no obstructions from the network? What port are to using in the client code? – Kelly S. French Oct 12 '16 at 17:58

1 Answers1

0

The issue was caused by an error in the server while binding the socket to the port.

Ajitav Dutta
  • 99
  • 1
  • 11