|
OMG, a java forum on Code Project... (first I thought is a usual joke,
a spoofed page or things like that, but I ended checking the hosting
domain and things like that, and now is clear).
Running out quickly...
|
|
|
|
|
haha.... some of us must still use java..... so I actually wish there was a link off of the message board pages. If more people knew about this board, and posted here. I would actaully be able to stay on Code Project all day, instead I now have to give my precious time to other web sites...ahhhh!!!
Brian Van Beek
Here's my boring blog! [^]
|
|
|
|
|
hey, HEY!, yeah you in the curly shirt. You forgot you coffee...
"God doesn't play dice" - Albert Einstein
"God not only plays dice, He sometimes throws the dices where they cannot be seen" - Niels Bohr
|
|
|
|
|
Have a LAN that my program runs on. I want it to broadcast out information so that any client
on any computer on the same subnet can receive it. The clients will have no idea what IP the
server is running on. I just want them to listen on a port. How do I go about this in a simple
way? If that's possible. The closes thing I've found is multicast but is that over-kill? Is
there a simpler way to do it than multicast?
Thanks,
Rex
I know you can't become if you only say what you would have done and you'll miss a million miles of fun." - Len
Work hard, play hard. Don't forget who you are and don't forget where you're from. Do all these things well and you won't have to wonder where you are going.
|
|
|
|
|
There are several divisions within any network solution. Multicast is a very efficient use of network infrastructure compared to broadcast. When you deal with multiple computers you can unicast to each in small numbers, but then as you said elsewhere you have to know your IPs and configure them appropriately.
Broadcast is the next step[^], which your network admit will kick your behind if you use it on a non-private network.
The design of a broadcast system has the clients listening to a port when the server broadcasts all computers receive the same message network-wide, even those not running your software. It's been ages since I did java broadcast, I do C/C++ right now, but my software still uses unicast/broadcast/multicast in different networks as appropriate.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Okay, that's about what I figured would be involved. Now I want to add the twist. In theory this works (in my head) what do you think? I'd like to bundle the program as one piece of code. If the server broacasts every 1 second then this is how I'd like to make the program run.
StartProgram{<br />
if(serverRunning)<br />
{<br />
assumeClientRole()<br />
}else{<br />
assumeServerRole()<br />
}<br />
<br />
serverRunning<br />
{<br />
ListenForServerWaitThreeSeconds<br />
}<br />
<br />
assumeClientRole<br />
{<br />
BeListenerAndListen <br />
}<br />
<br />
assumeServerRole<br />
{<br />
BeServerAndBroadcast<br />
}<br />
}
I know you can't become if you only say what you would have done and you'll miss a million miles of fun." - Len
Work hard, play hard. Don't forget who you are and don't forget where you're from. Do all these things well and you won't have to wonder where you are going.
|
|
|
|
|
About the only problem I can see is two computers starting software at about the same time. This produces a wait of three seconds of about the same time, network delays could make up for less than a second startup time. This may not be a problem as long as not tasks are started by autoscript.
I prefer a change in serverRunning to provide tertiary:
serverRunning
{
RequestServerIdentification
ListenForServer
if (replyfrom server) return true; // server online
RequestToBecomeServer
if (replyfrom server) return true; // deny server role, server online
VerifyServerRole
if (replyfrom server) return true; // deny server role, server online
}
It's somewhat overkill for most projects, however it also allows extension to design. For instance in a very important application you may want redundant networks with redundant servers. So one machine could be server on one network, another machine on the second network, all machines tie to both networks. This design allows you to make decisions based on that by validating server role by network. Even if a server exists on one network the server can ignore the request for server info on the other network thus allowing another machine to become server for that network. Once coded it's pretty easy to put logic in each decision process, and you have a double check in case one computer becomes the server while the other is going through the process. Time tagging time up in the message means that others receiving a time-online message longer than theirs drop out of the running for server, they see multiple machines vying for the server role and simply say a server exists because they see other clients trying to be promoted to server.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Yeah! I like that idea. Giving it a go now. Thanks for the advice that seems like a good way to go.
I know you can't become if you only say what you would have done and you'll miss a million miles of fun." - Len
Work hard, play hard. Don't forget who you are and don't forget where you're from. Do all these things well and you won't have to wonder where you are going.
|
|
|
|
|
code-frog wrote:
Yeah! I like that idea. Giving it a go now.
One other case you may consider, or not depending on app. I do redundant systems often, so the concept of computer failure is always on my mind.
Think on this scenerio:
You have a server, all is well.
Server machine dies, and comes back, this design allows it to return to being the server.
But what if the machine does not return. All clients are on the network, no one is the server. Do you declare the oldest client app as server afer x amount of time without a server?
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
This would actually be a requirement for what I'm trying to do. I do need a very redundant system and as each instance of the program will have a full copy of data from the current server any one of them could become the server then there would not be any data loss. The only impact would be expiring old server and promoting new server.
Using a timestamp for each client is a convenient way to establish leadership in the event of a missing server.
I figure I can manage everything in a timer event and then nest some loop processing. I want all the objects to be able to send a broadcast message that they are shutting down. There's no reason for the other systems to have to test for a missing server/client if it's not necessary. If the machine is being rebooted I have time to notify everyone. If the connection is lost then fault tolerance in clients will behave appropriately based on well test assumptions in the code.
//results = value returned from socket. Results is empty or not.
//resume = we have found old server or promoted new server now just keep listening as client or pumping if server.
//Program loads
()
//Timer Event that manages state of object.
{
If(results)
{
// stay as client
}
else
{
//We have missing results
loop->
{
//listen for server
}
}
if (serverFound)
{
//resume
}
else
{
//Promote oldest to new server.
//resume
}
}
I know you can't become if you only say what you would have done and you'll miss a million miles of fun." - Len
Work hard, play hard. Don't forget who you are and don't forget where you're from. Do all these things well and you won't have to wonder where you are going.
|
|
|
|
|
Java? sounds like an extinct animal or something - its on WWF
~Alexander Kent
|
|
|
|
|
I think it's on tour with Vanilla Ice or was it... Milli Vanilli? Hmm, don't remember.
I know you can't become if you only say what you would have done and you'll miss a million miles of fun." - Len
Work hard, play hard. Don't forget who you are and don't forget where you're from. Do all these things well and you won't have to wonder where you are going.
|
|
|
|
|
I know not many people are on this board, but I am trying to save a JTree to a database and am having a hard time trying to figure this one out. I was thinking of using arbitrary numbers to identify the parent node however I am struggling with this. Has anyone had any experience with this before? If so what were your solutions?
Thanks!
There are 10 kinds of people in this world. Those who understand binary and those who don't.
We shouldn't assume something's debugged just because everyone in the whole world has access to the source code.
|
|
|
|
|
I see no one really reads this still, but I was hoping a few people may see it. Anyway I am still working on saving a DefaultMutableTreeNode to the database and am having a tough time iterating through the tree. I am trying to write a recursive method to do so. Is this the correct way to do this and if anyone can try and show me an example that would be great! Thanks again!!
There are 10 kinds of people in this world. Those who understand binary and those who don't.
We shouldn't assume something's debugged just because everyone in the whole world has access to the source code.
|
|
|
|
|
I don´t tried this in real. But if you put a DefaultTableModel behinde the Jtabel. Than you can modify the Model and get a [][] of strings ( I think), this might help.
|
|
|
|
|
I was wondering if anyone knew of some good open-source/free jar files. I am looking for things like graphs, tables etc.
Thanks!
There are 10 kinds of people in this world. Those who understand binary and those who don't.
We shouldn't assume something's debugged just because everyone in the whole world has access to the source code.
|
|
|
|
|
|
Ok..just wondering if anyone else has run into this problem. At work we are building return url's to send to different apps. For this we use MessageFormat.format. for example
l_url = MessageFormat.format(<br />
l_url,<br />
new Object[] {<br />
"fooProcessing?foo=true",<br />
getUrlInfo(),<br />
getDeployment(),<br />
l_userId,<br />
l_returnJsp});
In this example, l_userId is of the object type Integer. Now, lets say for a moment that my userId is 1011. Now when I call the toString() function I get returned "1011". The MessageFormat.format however is somehow formatting l_userId to be "1,011." Which as you guessed, totally blew up our return urls, as when we go to convert that userId to an Integer, it doesn't like the commas. My question is, why did it do this? Shouldn't this just call a simple toString() implicitly as we are inserting them into a string? Another question I have is, if Integer can format that way (with the comma) why can't it take a number with commas in it when creating a new Integer?
Brian Van Beek
My Blog is Awesome, ok maybe not, but is still fun!!
|
|
|
|
|
Hey,
Well I figure I would post a question here becuase well I need an answer and no one ever posts here! I am sure this is a simple question but here goes. I am using the method startsWith that is a part of the String class and in the api it says that this will return true if an empty string is passed to the method. This is diffently not ok for what I am doing so I was wondering I would test for an empty string? Do I just do stringName.equals("") == true? Is there a solid way for me to test for this? Thanks for all of your help...well those that check this board!
There are 10 kinds of people in this world. Those who understand binary and those who don't.
We shouldn't assume something's debugged just because everyone in the whole world has access to the source code.
|
|
|
|
|
|
I was all excited that this bored may have started up again. I guess no one here really cares about java oh well. Atleast I know that 2 people check it
There are 10 kinds of people in this world. Those who understand binary and those who don't.
We shouldn't assume something's debugged just because everyone in the whole world has access to the source code.
|
|
|
|
|
BrockVnm wrote:
I guess no one here really cares about java
<paranoid>
Maybe Chris couldn't get a sponsor deal with Microsoft if he didn't close down the board?
</paranoid>
What puzzles me, is that there is still a Java Article Forum.
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
|
Hey,
I have a module that I have built that has uses swing. It has a table, an input panel and a bunch of buttons to do a few different tasks. The table is populated from the database and when the user enters his input vaules a column in the table gets populated. Now I have a button the user presses to print a report, a button the user presses to email his report and a user asked me to have a button that would just launch the email with the data dumped into the body of the email. So I have extracted the data and stored it into a StringBuffer. I have the data formated with tabs and returns. Now I am not sure how to lauch the default mail client. I tried doing it like so but it did not work because 1 my data was larger than 1K and 2 it does not support my tabs and returns:
cmd /c start \"\" \"mailto:?subject=test&body=" + body + "\""
Is there any way I can launch the default mail program and have my data dumped into the body of the email?
Thanks for all of your help! I have spent 2 days trying to figure this out and its driving me nutts!
There are 10 kinds of people in this world. Those who understand binary and those who don't.
We shouldn't assume something's debugged just because everyone in the whole world has access to the source code.
|
|
|
|
|
An applet can open the mail application like that:
getAppletContext().showDocument("mailto:me@me.net?subject=test&body=text");
An application should be able to do the same by writing the email and the SMTP headers into a .eml-file and then launching the file with the default application:
cmd /c start tmpFileName.eml
_________________________________
Please inform me about my English mistakes, I still try to learn your language!
|
|
|
|