Nvec
Junior Newbie
|
 |
«
Posted
2009-11-03 20:31:37 » |
|
Hello, im new in Java. I testing UDP Client + Server , but i don't know how fix errors. Maybe any can help me ? Im testing this tutorial : http://www.corvstudios.com/tutorials/udpMultiplayer.php Im run UDPServer.java and show on console: 1 2
| User-PC 169.254.181.57 |
I run UDPClient.java and show on console: 1 2 3 4 5 6 7 8 9 10 11 12 13
| java.net.SocketException: Unrecognized Windows Sockets error: 0: Cannot bind at java.net.PlainDatagramSocketImpl.bind0(Native Method) at java.net.PlainDatagramSocketImpl.bind(PlainDatagramSocketImpl.java:82) at java.net.DatagramSocket.bind(DatagramSocket.java:368) at java.net.DatagramSocket.<init>(DatagramSocket.java:210) at java.net.DatagramSocket.<init>(DatagramSocket.java:261) at java.net.DatagramSocket.<init>(DatagramSocket.java:234) at UDPServer.ServerThread.<init>(UDPServer.java:100) at UDPServer.Game.<init>(UDPServer.java:46) at UDPServer.UDPServer.main(UDPServer.java:22) Exception in thread "Server Thread" java.lang.NullPointerException at UDPServer.ServerThread.receivePacket(UDPServer.java:131) at UDPServer.ServerThread.run(UDPServer.java:115) |
Maybe any can help me ?  Thanks. 
|
|
|
|
|
DzzD
|
 |
«
Reply #1 - Posted
2009-11-03 23:27:22 » |
|
Hello, im new in Java. I testing UDP Client + Server , but i don't know how fix errors. Maybe any can help me ? Im testing this tutorial : http://www.corvstudios.com/tutorials/udpMultiplayer.php Im run UDPServer.java and show on console: 1 2
| User-PC 169.254.181.57 |
I run UDPClient.java and show on console: 1 2 3 4 5 6 7 8 9 10 11 12 13
| java.net.SocketException: Unrecognized Windows Sockets error: 0: Cannot bind at java.net.PlainDatagramSocketImpl.bind0(Native Method) at java.net.PlainDatagramSocketImpl.bind(PlainDatagramSocketImpl.java:82) at java.net.DatagramSocket.bind(DatagramSocket.java:368) at java.net.DatagramSocket.<init>(DatagramSocket.java:210) at java.net.DatagramSocket.<init>(DatagramSocket.java:261) at java.net.DatagramSocket.<init>(DatagramSocket.java:234) at UDPServer.ServerThread.<init>(UDPServer.java:100) at UDPServer.Game.<init>(UDPServer.java:46) at UDPServer.UDPServer.main(UDPServer.java:22) Exception in thread "Server Thread" java.lang.NullPointerException at UDPServer.ServerThread.receivePacket(UDPServer.java:131) at UDPServer.ServerThread.run(UDPServer.java:115) |
Maybe any can help me ?  Thanks.  no sure but maybe check your firewall ?
|
|
|
|
Nvec
Junior Newbie
|
 |
«
Reply #2 - Posted
2009-11-04 00:25:00 » |
|
Check , but error has not changed. And thanks for you reply DzzD!
|
|
|
|
|
Games published by our own members! Check 'em out!
|
|
|
|
DzzD
|
 |
«
Reply #4 - Posted
2009-11-04 01:05:34 » |
|
Seems to mean you might have something else running on the same port? (though that doesn't really make sense with UDP does it?) for a server it can but wait, I just looked the link you posted, do you run it from an Applet ?! if so maybe a security issue also becarefull on your IP vs localhost, if the server is bind to your ip you wont reach it with localhost and vice-versa
|
|
|
|
h3ckboy
|
 |
«
Reply #5 - Posted
2009-11-04 07:40:05 » |
|
have you tried it within your LAN before.
like without port forwarding?
|
|
|
|
|
Nvec
Junior Newbie
|
 |
«
Reply #6 - Posted
2009-11-04 14:48:34 » |
|
Thanks all for replys. Yes im use Windows 7 OS. Im trying change ports ( im trying download Port Scanner etc.  ) but error has not changed. Maybe any test this tutorial on Windows ? what you port use ?
|
|
|
|
|
h3ckboy
|
 |
«
Reply #7 - Posted
2009-11-04 18:47:59 » |
|
I have donet hat tutorial on windows XP.
I used the default port.
I noticed that you are not using a local ip. you should try to do it with "localhost" and run both the client and the server on the same computer.
|
|
|
|
|
Corvinex
Senior Member    Projects: 1
Work Hard, Go Pro.
|
 |
«
Reply #8 - Posted
2009-11-04 21:48:14 » |
|
Hello, im new in Java. I testing UDP Client + Server , but i don't know how fix errors. Maybe any can help me ? Im testing this tutorial : http://www.corvstudios.com/tutorials/udpMultiplayer.php Im run UDPServer.java and show on console: 1 2
| User-PC 169.254.181.57 |
I run UDPClient.java and show on console: 1 2 3 4 5 6 7 8 9 10 11 12 13
| java.net.SocketException: Unrecognized Windows Sockets error: 0: Cannot bind at java.net.PlainDatagramSocketImpl.bind0(Native Method) at java.net.PlainDatagramSocketImpl.bind(PlainDatagramSocketImpl.java:82) at java.net.DatagramSocket.bind(DatagramSocket.java:368) at java.net.DatagramSocket.<init>(DatagramSocket.java:210) at java.net.DatagramSocket.<init>(DatagramSocket.java:261) at java.net.DatagramSocket.<init>(DatagramSocket.java:234) at UDPServer.ServerThread.<init>(UDPServer.java:100) at UDPServer.Game.<init>(UDPServer.java:46) at UDPServer.UDPServer.main(UDPServer.java:22) Exception in thread "Server Thread" java.lang.NullPointerException at UDPServer.ServerThread.receivePacket(UDPServer.java:131) at UDPServer.ServerThread.run(UDPServer.java:115) |
Maybe any can help me ?  Thanks.  It looks like your trying to run the server twice? If the client attempts to run, and you get UDPServer.java output then it seems like your IDE setup for running two separate java projects is running the same one.
|
|
|
|
Nvec
Junior Newbie
|
 |
«
Reply #9 - Posted
2009-11-04 22:11:33 » |
|
Thanks Corvinex and other for replys  but error im can't/don't fixed  . Corvinex maybe yau have compile this tutorial ? maybe can share ?  I think in order then to understand me, why im can't running. 
|
|
|
|
|
Games published by our own members! Check 'em out!
|
|
Karmington
|
 |
«
Reply #10 - Posted
2009-11-06 16:49:30 » |
|
Kay, let's walk through this, I just built the thing on eclipse and it worked fine. Ouput: owner-c6f2b00d5 192.168.100.22 null Connected , then i get the circle moved on the screen with wasd.
How I built the project: 1) New Project 2) New Package, udpserver and udpclient 3) New Class, UDPServer in udpserver package and UDPClient in udpclient package 4) Copy code into the empty classes. 5) run server, run client.
Works for me. Socket bind exception is indeed most common if you have already bound the socket. Check you have no other instances running. java.net.BindException: Address already in use: Cannot bind at java.net.PlainDatagramSocketImpl.bind0(Native Method) comes for me if I try to launch another server.Make sure you terminate all the runners properly. Use the red square to terminate. 8 steps right from the red stop button is a console selector, 'Display Selected Console', which should show you all running instances.
This will be particularly important to handle properly when you put this stuff on to the actual server, if you forget a running program it will keep blocking that port from new instances of the program.
|
|
|
|
delt0r
|
 |
«
Reply #11 - Posted
2009-11-06 17:04:19 » |
|
A problem we had once was that windows didn't properly clean up a previous bind. A restart did fix it, but we went for the add one to the port number each time or pick a random port number. This was on XP however. Also you need special permission to bind to ports below 1024.
|
I have no special talents. I am only passionately curious.--Albert Einstein
|
|
|
Sueamanu
Senior Newbie 
|
 |
«
Reply #12 - Posted
2009-11-06 20:56:56 » |
|
Yes work, but get on Applet error maybe any can help ? 1 2 3 4 5 6 7 8 9 10 11 12
| java.lang.NoClassDefFoundError: UDPClient (wrong name: UDPClient/UDPClient) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source) at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Exception: java.lang.NoClassDefFoundError: UDPClient (wrong name: UDPClient/UDPClient) |
|
|
|
|
|
DzzD
|
 |
«
Reply #13 - Posted
2009-11-06 22:13:39 » |
|
Yes work, but get on Applet error maybe any can help ? 1 2 3 4 5 6 7 8 9 10 11 12
| java.lang.NoClassDefFoundError: UDPClient (wrong name: UDPClient/UDPClient) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source) at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Exception: java.lang.NoClassDefFoundError: UDPClient (wrong name: UDPClient/UDPClient) |
wrong package name (can you opst your applet code?)
|
|
|
|
Sueamanu
Senior Newbie 
|
 |
«
Reply #14 - Posted
2009-11-12 17:33:37 » |
|
Thanks. 
|
|
|
|
|
Sueamanu
Senior Newbie 
|
 |
«
Reply #15 - Posted
2009-11-20 14:19:38 » |
|
Applet HTML code: 1 2 3 4 5 6 7 8 9 10
| <html> <head> </head> <body> <applet code="UDPClient.class" width="640" height="480"> <param name="username" value="Guest"> <param name="ip" value="localhost"> </applet> </body> </html> |
Error: 1 2 3 4 5 6 7 8 9 10 11 12
| java.lang.NoClassDefFoundError: UDPClient (wrong name: UDPClient/UDPClient) at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source) at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Exception: java.lang.NoClassDefFoundError: UDPClient (wrong name: UDPClient/UDPClient) |
|
|
|
|
|
indexunknown
|
 |
«
Reply #16 - Posted
2009-11-20 14:54:12 » |
|
If u have exported it into a .jar then u need to put it into the tag <applet code="UDPClient.class" archive="jar name goes here" width="640" height="480"> also make sure all the files are in same directory with the page.html .
|
|
|
|
|
Sueamanu
Senior Newbie 
|
 |
«
Reply #17 - Posted
2009-11-20 17:31:59 » |
|
I'm test and too get error ( error don't change ).
|
|
|
|
|
Corvinex
Senior Member    Projects: 1
Work Hard, Go Pro.
|
 |
«
Reply #18 - Posted
2009-11-20 20:42:52 » |
|
Yea, make sure the UDPClient.class file is going into the same directory as your applet .html file. I reproduced your error by not having the .class files in the same folder as the .html file: 1 2 3 4 5 6 7 8
| java.lang.ClassNotFoundException: UDPClient.class at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source) at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source) at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source) at java.lang.Thread.run(Unknown Source) |
this is what your folder should contain UDPClient - Player.class
- PlayerList.class
- ReceiveThread.class
- UDPClient.class
- UDPClient.html
and then double click UDPClient.html, and the client should run.
|
|
|
|
Sueamanu
Senior Newbie 
|
 |
«
Reply #19 - Posted
2009-11-20 21:44:35 » |
|
.
|
|
|
|
|
indexunknown
|
 |
«
Reply #20 - Posted
2009-11-20 21:56:08 » |
|
if the class is in package UDPClient then u need <applet code="UDPClient/UDPClient.class" archive="UDPClient.jar" width="640" height="480">
probably without archive then: <applet code="UDPClient/UDPClient.class" width="640" height="480">
|
|
|
|
|
Sueamanu
Senior Newbie 
|
 |
«
Reply #21 - Posted
2009-11-20 22:15:17 » |
|
Yes! work! , but i'm on client can't move ball and other. Thanks all for help and reply's!
|
|
|
|
|
|