aspose file tools*
The moose likes I/O and Streams and the fly likes Error in Connection using Sockets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Error in Connection using Sockets" Watch "Error in Connection using Sockets" New topic
Author

Error in Connection using Sockets

Andy Richard
Ranch Hand

Joined: Oct 22, 2013
Posts: 47
Well guys, i'm totally new to Java..
I made the following stuff.. it runs, but no action is performed when i try to send it.
The cod is,



The errors i got are..
run:

I don't understand any part of error here..What exactly are these errrors, and how to re-solve 'em ??
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2310
    
  49
The first exception is thrown because the socket was unable to connect to anything. Presumably you don't have anything listening for a connection on port 4000 on the localhost.
The other exceptions were thrown because your code ignores the fact that there is no connection and carries on as if there was one. Unfortunately the reader and writer objects haven't been created because of the first exception, hence the NPE's.
Andy Richard
Ranch Hand

Joined: Oct 22, 2013
Posts: 47
Tony Docherty wrote:The first exception is thrown because the socket was unable to connect to anything. Presumably you don't have anything listening for a connection on port 4000 on the localhost.

What does that means?
How can i make something listen to that port ??
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2310
    
  49
You need to create a ServerSocket to accept the connection, receive whatever the socket sends and then send something back.

I suggest you read http://docs.oracle.com/javase/tutorial/networking/sockets/index.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error in Connection using Sockets