|
-
Problem with Socket :: java.net.ConnectException
Hi,
I am new to socket programming but have experience in Java.
My desktop is connected to the institute LAN and that is how I connect to the rest of the planet.
Now I was trying to make a file tranfer protocol. The socket part of the code is :
For Server:
InetAddress IPServer = InetAddress.getByName("172.26.94.199");
ServerSocket serSoc = new ServerSocket(8000,50, IPServer);
while(true) {
soc = serSoc.accept();
start();
}
For Client
InetAddress serverIP = InetAddress.getByName("172.26.94.199");
soc = new Socket(serverIP, 8000);
When I run the client i get the Exception :
java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:364)
at java.net.Socket.connect(Socket.java:507)
The code was working brilliantly till I was using 'localhost', ie :
For Server :
ServerSocket serSoc = new ServerSocket(8000);
while(true) {
soc = serSoc.accept();
start();
}
For Client :
soc = new Socket("localhost", 8000);
Please help me. I just can't figure out the problem.
Similar Threads
-
By vikassheelgupta in forum Java
Replies: 0
Last Post: 07-22-2005, 05:35 AM
-
Replies: 0
Last Post: 03-18-2005, 08:57 AM
-
Replies: 3
Last Post: 03-07-2005, 02:34 AM
-
Replies: 0
Last Post: 06-12-2002, 08:21 PM
-
Replies: 0
Last Post: 12-13-2001, 12:06 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks