This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes how to give port number for socket class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "how to give port number for socket class" Watch "how to give port number for socket class" New topic
Author

how to give port number for socket class

vijayakumar durai
Ranch Hand

Joined: Aug 18, 2008
Posts: 153
how to give port number in socket class?

Socket sc=new Socket(hostname,portnumber);

can anybody tell about hostname,portnumber
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8836
    
    7

If you look at the JavaDoc for Socket, it says:
public Socket(String host, int port)


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
vijayakumar durai
Ranch Hand

Joined: Aug 18, 2008
Posts: 153
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

Joined: Oct 29, 2001
Posts: 8836
    
    7

"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.
 
subject: how to give port number for socket class
 
Similar Threads
Initial design review
applet servlet communication
port number
bugs in client\server program - can't connect to remote server
InetAddress class