• Post Reply Bookmark Topic Watch Topic
  • New Topic

Socket client unable to contact server on local host  RSS feed

 
John Pa
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I am running a server on the local host and want my client to connect to it.It is unable to connect and I get a connection refused error.I was running a firewall which I shutdown and tried but still did not make any headway.
The code is as below
-------------------------------------------
try { // initialize socket
this.remoteAddr = remoteAddr;
this.port = port;
socket = new Socket(remoteAddr, port);
out = new PrintStream(socket.getOutputStream());
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
}
catch (Exception e) {
System.out.println(e);
JOptionPane.showMessageDialog(null,
"Could not connect to server, aborting...!");
System.exit(0);
}
----------------------------
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!