• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to give port number for socket class

 
vijayakumar durai
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how to give port number in socket class?

Socket sc=new Socket(hostname,portnumber);

can anybody tell about hostname,portnumber
 
Joe Ess
Bartender
Pie
Posts: 9266
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you look at the JavaDoc for Socket, it says:
public Socket(String host, int port)
 
vijayakumar durai
Ranch Hand
Posts: 153
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this tutorial not explain how to give port number i gave port number 1748 it give error
java.net.connectionexception connection refuse can any body tell how to give port number?
 
Joe Ess
Bartender
Pie
Posts: 9266
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"java.net.connectionexception connection refuse" indicates that either there is no service listening to the port you have specified or that the port is blocked. You are passing the port number correctly, there's nothing for it to connect to.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic