File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Sockets and Internet Protocols and the fly likes java.net.Connect Exception: Connection refused java.lang.Null Pointer Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "java.net.Connect Exception: Connection refused java.lang.Null Pointer Exception" Watch "java.net.Connect Exception: Connection refused java.lang.Null Pointer Exception" New topic
Author

java.net.Connect Exception: Connection refused java.lang.Null Pointer Exception

sudipto shekhar
Ranch Hand

Joined: Apr 02, 2008
Posts: 813

I have a simple chat application.
The client and the server are connected through broadband internet.
After starting the chat server on one machine, when the client-side code is run it shows the following error:

java.net.ConnectException: Connection refused
java.lang.NullPointerException;

client side code:

Socket server;
Thread t;
public ChatClient()
{
super("CLIENT");
try
{
server=new Socket("192.168.01.11",5005);// IP add & Port no. of the host.

}
catch(Exception e)
{
System.out.println(e);
}

__________________________


With Regards,

Sudipto Shekhar.


Regards, Sud.
SCJP 5 ScjpFAQ JLS
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 685
Post the full text of the error message. Is there a line number in the error message showing where the error occurred? Look at that line and see what object reference was null.
sudipto shekhar
Ranch Hand

Joined: Apr 02, 2008
Posts: 813

No, there was no line number or as such in the above mentioned error.
The error was as it is?
The IP add is that of the host.
The client and server are both connected through broadband internet.
What address should i use?
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8711
    
    6

The ip address 192.168.*.* among others is not addressable across the internet. Those addresses are intended for use on private networks.
You will have to figure out the public address of your internet connections, then configure the broadband routers to allow connections to pass through.


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

Joined: Apr 02, 2008
Posts: 813

which http protocol is to be used for broadband internet connection in place?is there any such facility?
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8711
    
    6

I don't understand your question. There is only one HTTP. Correct me if I'm wrong, but since you are using Sockets rather than URL/URLConnection, I don't think you are using HTTP in your application.
Are you talking about configuring port forwarding? The settings differ depending on your router/modem. This site can help you with that task.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.net.Connect Exception: Connection refused java.lang.Null Pointer Exception
 
Similar Threads
chat idea
Closing sockets
Please find the problem in this code.
Connection Refused Error
Socket client unable to contact server on local host