Forums Register Login

UDP Datagram Connection

+Pie Number of slices to send: Send
Hi, i'm trying to understand this program. I got the drawing part and converting the brush strokes into packets. but i don't get the connection part. (Ultimately when i compile the program nothing comes out. it only displays: Usage: java Draw <my port> <remote host> <remote port>. could someone please verify what is wrong? Million thanks for the help.

As for the connection code i don't get is:
What does this do?



+Pie Number of slices to send: Send
The message is telling you that you need to supply arguments.

e.g: java Draw 30000 remote.host 30000

It appears to be sending the local drawings to the remote server.

WP
+Pie Number of slices to send: Send
Sorry for my lack of knowledge...
how do i supply arguments?
+Pie Number of slices to send: Send
At command line/prompt whatever:

$ java Draw 30000 127.0.0.1 30001

or

C:\java Draw 30000 127.0.0.1 30001

The application is telling you what it needs !

BTW: It doesn't work. ;)

that's for a later discussion ...

WP
+Pie Number of slices to send: Send
i see. thanks for trying it out for me.
i'm not quite sure but is this written in an internet form or a local form....
what if i want to change it such that it connects to a localhost instead...which part should i change?
+Pie Number of slices to send: Send
The remote host is the server that whatever you draw is sent to.
The remote port is whatever port is it listening on.

Local port is setup on your local running "Draw.class" to listen for responses from server.


Can you even run this, using: java Draw 30000 127.0.0.1 30001

You should get a GUI that allows you to draw things.

WP
+Pie Number of slices to send: Send
after i compile and run it using jCreator it shows



nothing comes out even after i enter the port,remote host and remote port...
the code should be working i think as when i got it i was told it was working and taken from a class lesson.
+Pie Number of slices to send: Send
I have no idea what jCreator is doing... but it looks like you are not passing the parameters!

Find the compiled Class file (java.class) and run it from a command line.

jCreator may also have ways to pass program arguments.

When IDEs start to confuse you it is time to either;

1. Learn the IDE (Use the help function)
2. Get a better IDE
3. Go back to basics and use the command line

e.g:


NOTE: I added some System.outs in there to get the thing to run.

WP

+Pie Number of slices to send: Send
i tested using cmd and this is what i got...


i'm starting to wonder if it is my JDK problem....
you said you added some System.outs in the code, care to share it please?
+Pie Number of slices to send: Send
If you can compile, your JDK is fine.

It looks like you have a major runtime (JRE) problem.

Where is your java installed?

What is the version (java -version) ?

Etc..

You've got issues.

WP
+Pie Number of slices to send: Send
i re-installed my JRE and it works using the cmd method. thanks!

However i tried running two of the same application and they don't seem to function the way they are supposed to.

When i draw on one board the other doesn't receive it.
I used these arguments for both windows 30000 127.0.0.1 30001. do i have to alter them?
+Pie Number of slices to send: Send
CONGRATULATIONS!

No..

You need to run two instances on different ports, e.g:

java Draw 30000 127.0.0.1 30001

and (another cmd prompt)

java Draw 30001 127.0.0.1 30000

WP

+Pie Number of slices to send: Send
Thank you for your help and patience! after posting the question i kinda figured it out and tried it however it did not work...i even created another Draw file and renamed it and tested it. but it still won't send....
could you do me another favor by testing it out please?
+Pie Number of slices to send: Send
I already did, and hinted that you would have problems with the application early on in the thread.

You DO NOT need to rename or copy anything, simply start two Draws in two different windows
with different parameters, as I've already (patiently) told you.

What are you trying to do?

Do you know Java? I get a sense you are quite new.

Yes, I've tested it, and changed the code to make it work. I can draw in one window and see it in another.

Is this an assignment, a test of some kind to make this work?

For example:

Look carefully through the run() method. Do you see anywhere that message is actually populated with a String??

NO! It's null! and split() throws a NullPointerException!

I do, can and will help, but you have to be honest here as to your capabilities.

WP

Unless this is an interview for me ... ;)
+Pie Number of slices to send: Send
sorry for not stating what i was trying to do at first. Little introduction on my situation:
I know java but i'm not that good in it. i've learned C++, VB, HTML,PHP within 1 year a few years ago in school. The school didn't really care about our knowledge as long as we managed to pass.
End of last year I started JAVA classes(as required by my school) Recently(within this year) I've been given JAVA assignments to do and managed to complete. All which were object oriented programming. All which i did through trial and error(and which was relatively easy), my grasp of JAVA(and other programming) is not good. If the code is easy(doesn't point here and there) i will understand. I've relied on Head-First JAVA book to pass so far.

This is an assignment for a subject called Operating Systems and Networking.
Part 2 of the assignment actually.
Part 1 required me to create a simple instant messenger which i managed to.
Part 2 requires me to select a more complex networking program. I have options, to code it myself(which has extra credit) or to take it from the net(which has less credit, which i intend to do) but to give reference to it. Then i will have to write a detailed report on step by step how does the program work. The reason i ended up doing something like this(whiteboard) was because i was given such a title. The title however, i find is too complex for me. Other titles were taken by my other classmates. I can't appeal to the school because its holiday now. The code was given to me by someone who found it online from some academic archive.

thanks for the help so far, really appreciate it and i hope you will be able to continue to help me.
+Pie Number of slices to send: Send
Thanks for the honesty..

Draw.java does not work. You know this right?

You are able to run two instances (on different ports) but they cannot talk to each other.

The networking aspect is easy, send a UDP packet to some server, that server receives it.
UDP has none (if very minimal handshaking).


This example off the "net" seems to be more of a "Make this work" exercise"

From what you posted, I had to make a number of changes. Some are quite significant.

It works and looks quite nice when running though.

I do not think you have the expertise to make this work, maybe you will.

My question again is, what is the deliverable of the assignment? An essay?

WP


+Pie Number of slices to send: Send
Edit: i was not aware that Draw doesn't work until you told me.

There are 2 diff types of deliverable (verbally told by the teacher at least) the teacher is giving us leniency as she knows our programming is weak and we were not scheduled to take this subject until we completed a subject called Data structures or something....but the time table changed and we ended up taking the networking subject first.
Anyway back to the deliverable:

Case 1
If the student wishes to write the code on his own. the code will be ran through a system to check for plagiarism online. If none is found the student is then interviewed by the teacher to ask him to explain the code. eg.like what does this part of the code do? how did you achieve this? if no folly is detected then the student gets marks and doesn't need to write a report.

Case 2(the lenient one)<<the one i'm choosing
If the student can't produce the code himself, he can get it from the internet or the library. However, by doing this the student forfeits a portion of marks and is required to write a report explaining in detail (to prove) that the student understands the code. Edit: the report is an essay.

I found other examples of these type of whiteboard programs but they are even more complex....some are even complete with login systems and broadcast to many users.
I asked the classmate who gave me the code. he gave me the link where he got it from. http://people.dsv.su.se/~vero-rar/java/Draw.java which i am shocked as i don't know what language is that...
Thank you my well lotioned goddess! Here, have my favorite tiny ad!
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1532 times.
Similar Threads
Pinger time!
DNS query, protocol
developing tftp application in java
Hint needed: TCP -> UDP , test on localhost
Writing a class that receive and broadcast at the same time
Problem in sending a packet
datagram packets. UDPReceive sends an acknowledgment when it receives a datagram...
How to send Datagram packet to another network without port forwarding?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 05:13:30.