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 Sockets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Sockets" Watch "Sockets" New topic
Author

Sockets

maya jain
Greenhorn

Joined: Feb 22, 2011
Posts: 5
Hi,

I am doing a client server program, The program works on the same computer (localhost), but if I give the name of another computer "MAYA-PC" I am getting the following error

java.net.UnknownHostException: MAYA-PC
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at type1.<init>(type1.java:65)
at type1.keys(type1.java:271)
at type1.access$0(type1.java:264)
at type1$1.run(type1.java:51)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierar chy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

why is this happening. Both the computers are connected to the same network

But on my computer MAYA-PC, which have both client and server program, even if I give socket = new Socket("MAYA-PC", 7777);....I am getting output. I thought that it may be a network problem and tried working client and server programs on different computers on another network too. But I got the same error.

Please Help me.

Regards,
Maya
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1398
    
    6

Instead of name, if you use IP address does it work?


Swastik
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sockets
 
Similar Threads
Sockets under Windows XP OS
Doubt in Sockets!!
java.net.ConnectException: Connection timed out: connect
Client/Server Communication Problem
Problem with Testing my RMI BusinessLogic with more than 200 Threads