• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sockets

 
maya jain
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1603
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of name, if you use IP address does it work?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic