Comparison of RMI and serialized object over TCP/IP
I do not know quite clearly the advantages and disadvantages of the two tech. Could anybody advise in which sitution I shall use this or that?
Thanks
Let's assume you have some kind of a distribuited - client/server application in mind.
OK - You see that you need to pass data back and forth, and you COULD serialize the data and pass it over TCPIP.
So how would you make a request to do something?
Example: Ask for a computation to be performed?
Example: Ask for a database to be searched and selected data to be returned?
Example: Ask for a database to be updated?
How would you communicate the fact that a request was illegal - say an attemnpt to withdraw money from an account with no balance?
Remote Method Invocation is one way to get the serialization, data transfer, AND formulate requests and get results.
Similar Messages
-
Can I render a Flash frame as a bitmap and send it over TCP/IP?
I want to draw some combination of bitmaps, flash shapes, vectors, text etc and draw them programmatically into my movie using ActionScript, and then get every "rendered" pixel of my movie (at 100% view) into an array that I send to another program over TCP/IP. Can anyone help me here?
The first part of the question is if its possible to render a frame that is a collection of Flash elements as a bitmap? I know that I can iterate through a bitmap and get every pixel using the getPixel method but I'm trying to access the final rendered frame displayed on my screen, including, as I said Flash shapes and text.
The second question is what would be the best way to send this "video frame" over TCP/IP? Would I use an XML socket connection? That is the only way I know how to send data out of Flash over TCP/IP but I don't know if it is the only way - the help page says the data needs to be formatted as XML, which seems unwieldly for this application.
I'm doing this now by using Max/MSP/Jitter to do a screen capture the size and location of my Flash movie and then send out the resulting matrix using a "jit.net.send" object (which lets you send frames of video over TCP/IP), but this is too clumsy for the installation I am building.
Any help would be greatly appreciated!
-bobThanks! That was exactly what I was looking for in the first half of the question. And I guess the draw() method works in AS2 as well as AS3. I will test it but from what I understand, I can use a Bitmap as kind of my bottom-level container, then create (in ActionScript) a movie clip that can contain other movie clips or drawing API commands or whatever, animate these various elements then finally draw() them into the bitmap. I see that in AS3 I can even use getPixels or getVector to capture the full "video frame" in one line of code.
Thanks rothrock, for the helpful links. My application is kind of unusual, in that I'm sending "video" data to a proprietary LED controller box for display on a low resolution LED display. I connect to the box over TCP/IP and send it "frames of video" 20 times a second. I got this to work with this other content and software (Max/MSP/Jitter) and I want to see how I could capture all the rendered pixel data in successive frames of Flash animation, format it properly, then send it over TCP/IP to this controller box. Don't really now enough about the various flavors of TCP/IP connections to figure out how to do this in Flash, and I know there are security limitations built in to Flash that have to be worked around. But my movies are small (say 96 pixels by 72 pixels) and I need to send uncompressed data directly to my controller box, so these interesting links showing how to use server-side scripts to create jpgs or pngs are probably not going to help me. I will hopefully find a higher-level programmer than myself to work this out, and I think some of the techniques here will hopefull prove to be helpful.
Thanks again for your help! -
Help need for sending object over TCP Connection
I have
ResultSet rs = (ResultSet)connection.getObject(1)
and i have user's connection connected on a port
Currently i am reading while rs.next elements , preparing somestring and i am using socket_connection.send('to_myuser',somestring) to send message
and user receive it like (while input_stream.readLine() != null )
etc .etc.. i am just writing some algorithm which very common.
i want to reduce this recursion on the my server end and once user receive it , and to get all result set retrieved from that end.
my question is , is it possible to send
connection.send('myuser',rs);
and how to read on the other end.
Thanks in advanceJust want to clarify how we can cache it..? I belive
we have to put data somewher in the ArrayList or
something ....which one major taskOf course caching requires that you store it in something.
>
second, you need a very good algorighm to query all
your collections ... i think oracle SQL mechanism is
very nice.... however in your recommended approach i
have to write lots of searching and sorting
alrogrthm... .correct?Generally no. Requests are usually limited to very few parameters and often limited only to one or zero. Thus a user first gets a list of customer names (no parameters for query) and then request the detail about a specific customer (using the customer id which is only one parameter.)
Note that you mentioned large amounts of data. You didn't specify what large meant. However large requests should never be allowed from users (people). They can't use it anyways. Automated processes should be architected to provide for a technological solution with is cost effective. -
Hi,
I am doing project for uni of noughts and crosses game over TCP. This is my second project in Labview, I am autodidact. I know that in my program are a lot of this to make them better or to replace with more optimal sulutions (even notifiers), but I am on finish of the game, the next one will be better!
So the problem is in file client.vi, probably it is not complicated. Function Search and Replace String does not replace me anything. If You have some time (I suppose that not much than 10 min) check it please. Code is commented.
The file client.vi shoud only indicate the situation on the board.
Great thanks! I wish I could do something to repay You.
Best regards
P.S. Three remaining files (subvi's) are in post below
Attachments:
client.vi 32 KB
main.vi 106 KBMissing files
(Porównywator means comparator )
Attachments:
arraytostring.vi 31 KB
stringtoarray.vi 37 KB
Porównywator.vi 24 KB -
Bizarre ClassCastException when sending serialized objects
I have two programs communicating with each other over a network using TCP and serialized objects. One of the programs uses an ObjectOutputStream to send the message, and the other uses an ObjectInputStream to receive it. The receiver has a thread that simply loops, receiving and processing messages one at a time.
Under normal circumstances, this works fine. However, sometimes the sender program has to send more than one message, one right after the other. I guess my assumption was that on the receiving end, they would somehow just "queue up" in the ObjectInputStream and the receiver would be able to read them one at a time. But instead, I get this bizarre ClassCastException whose message talks about members and objects from both messages that were sent. It is as though somehow the two objects received are being mangled together and interpreted somehow as one object. This is strange to me, since I am pretty sure TCP is supposed to guarantee in-order delivery of packets.
Can I not send multiple messages right after each other through an ObjectOutputStream and have them received in an ObjectInputStream? If not, what would be a good workaround?
If you need more details, it works like this. I have two classes that look like this:
class Class1 extends SerializableSuperclass
Member1 m1;
class Class2 extends SerializableSuperclass
Member2 m2;
}Sender sends an instance of Class1 and then immediately an instance of Class2. Receiver attempts to readObject() from the input stream and gets this exception:
Exception in thread "Thread-4" java.lang.ClassCastException: cannot assign instance of Class2 to field Class1.m1 of type Member1 in instance Class1
Isn't that bizarre? Two separate classes, and it is attempting to merge the two in some odd way.
How do I fix or work around this?
ThanksThese classes do not have those methods. They are simply message classes designed to hold data. Do you need to see the methods that call ObjectOutputStream's writeObject() and ObjectInputStream's readObject() methods?
The serializable superclass is there because it has other stuff including a field identifying the sender. It's basically a base message class.
Also, the member classes are serializable (serializability isn't the issue anyway; "class cast" is the issue). -
Applet/Servlet/serialized objects/HTTPS/Intranet problem
We've got a Webapplication with[b] applets on the client and servlets on the server side.The Applet send serialized Objects over HTTPS (SSL) to the servlet. The servlet does some business logic and send the answer the same way back.
In all our tests and in the most cases the application works without any problems.
But in some Intranet environments we get occasionally (not definitely reproducable) the following error:
<Oct 1, 2004 8:26:00 AM> [AnmeldenService] {Service-readThreadAks-AnmeldenServiceThread}
java.io.EOFException: Expecting code
at java.io.ObjectInputStream.peekCode(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at com.dsh.egb.aks.betrieb.rclt.service.ServiceThread$2.run(ServiceThread.java:222)
at java.lang.Thread.run(Unknown Source)Has anybody an idea how to further analyse this problem?
Thanks,
Mark
We use JRE/JDK 1.3.1_10.Here some more Information about our environment:
Server: Apache 1.3.26 / Openssl 0.9.6d /WinNT 4.0 /HTTP Redirect to Tomcat 4.0.1/ JDK1.3.1_10/ WinNT 4.0
Client: Plugin 1.3.1_10/Internet Explorer 6.0 (SSL)/Win NT 4.0 -
Modbus RTU over TCP (Simex Transmitte​r and Advantech Server)
Hey Guys,
somehow i am not able to get a connection over TCP IP using RTU Mode (reading values) from a transmitter which is hooked up to an advantech EKI 1542 Server. The Port is configured as an RS 485.
i am using the modbus library and i tried to adjust the MB serial read holding registers vi to accept a TCP IP Socket input instead of an INSTR. Do you have any suggestions?
Thanks a lot for the forum support!Hi Christo and welcome to NI Forums!
Is this the ModBus library you are using? If so, I'd recomend to check out the newer, object based library available here. It has a more straightforward setup, especially for using TCP connections. You'll find an example VI for using a master, as well as a slave device, and these you'll be able to use right away without much modification. The code'll look like:
Please test your device communication using this library.
Kind regards:
Andrew Valko
NI Hungary
Andrew Valko
National Instruments Hungary -
Sending Custom objects over RMI
I am new to RMI and am having trouble sending customised objects over an RMI connection - I am trying to send an object of class DataFile which implements serializable, to a method on the server called loadPerformanceData(DataFile data). Here is the class DataFile:
package org.twomey.fyp.loader;
import java.io.*;
import java.util.*;
import java.text.*;
import org.twomey.fyp.mail.*;
* Class to accept a File Object to prepare a File for Data Loading.
* It reads a Data File line-by-line and provides the functionality
* to insert line records into the database.
* @version 0.1
* @author Sean Twomey
public class DataFile implements Serializable{
/** Data Loading Date */
private String date;
/** Log from Loading Process */
private StringBuffer log;
/** Array of lines from file */
private String file[];
* Constructs a Data File from a specified File Object.
* Accepts the File object and Data Loading Date
* @param inputFile Inputted File Object
* @param date Data Loading Date
public DataFile(File inputFile, Calendar date){
// Formats the date into a form acceptable to Oracle DBMS
SimpleDateFormat form = new SimpleDateFormat("dd-MMM-yy");
this.date = form.format(date.getTime());
String line;
int count = 0;
try{
RandomAccessFile inFile = new RandomAccessFile(inputFile, "r");
// Read until end-of-file counting lines
while((line = inFile.readLine()) != null){
count++;
// Initialise array size to number of lines.
file = new String[count];
// Return to start-of-file
inFile.seek(0);
for(int i=0;i < file.length;i++){
// Read line into array
file[i] = inFile.readLine();
inFile.close();
catch(IOException ie){
System.err.println("IO Exception: " + ie);
* Load the entire set of records into the Database.
* Data is loaded line-by-line. A Data Record object
* is initilised to perform record loading and the
* insertRecord method is called for each record.
* A log is compiled from the insertion process
* @return The Process Log
public StringBuffer loadData(){
String record[];
log = new StringBuffer("");
System.out.println("HERE");
System.out.println(file.length);
// From the org.twomey.fyp.loader package
DataRecord objRecord;
objRecord = new DataRecord(date);
// Line-by-Line
for(int i = 0; i < file.length; i++){
// Split the record into fields which have been tab-delimited
record = file.split("\t");
// Each record feed must be 12 fields for valid loading
if(record.length != 12){
System.err.println("Invalid Feed for line " + (i+1));
log.append("Invalid Feed for Line " + (i+1) + "\n");
else{
log.append("Line "+(i+1) + " " objRecord.insertRecord(record) "\n");
return log;
* Send an EMail upon Completion the Performance Data Loading Process.
* The mail sents the log compiled during Data Loading.
public void sendMailReport(){
// Use the Mail class from the org.twomey.mail package
Mail email;
String from;
String alias;
String to[];
String subject;
email = new Mail("chara.ucc.ie");
to = getAddresses();
from = System.getProperty("user.name") + "@chara.ucc.ie";
alias = "Sheet Generator System";
subject = "Performance Data Loader Report";
email.sendEMail(from,alias,to,null,null,subject,log.toString());
* Returns Email addresses from file.
* The <b>mail.config</b> file is read line-by-line.
* Each line entry should correspond to an email address.
* @return Email addresses in a <CODE>String</CODE> array
private String[] getAddresses(){
RandomAccessFile inFile;
String strLine;
String addresses[] = null;
int count = 0;
try{
inFile = new RandomAccessFile(new File("mail.config"),"r");
while((strLine = inFile.readLine())!= null){
count++;
addresses = new String[count];
inFile.seek(0);
for(int i = 0; i < addresses.length; i++){
addresses[i] = inFile.readLine();
catch(IOException ie){
System.err.println("IOException: " + ie.getMessage());
return addresses;
} // end getAddresses
} // end ClassYou seem to be reading the file into a string array, then trying to pass the object that did the reading.
Two alternatives:
o Just pass the string array object.
o Create a data only object, passing the string array as an argument to the constructor -
Hi - I would like to build the logic in which it should accomodate the communication redundancy using serial RS-232 for Data Transfer b/w Host and RT irrespective of TCP/IP Data Transfer.
I want to do data transfer b/w host and RT through RS232 VISA portal whenever TCP/IP ethernet cable has been unplugged from the controller continuosly , it should keep on checking for TCP/IP link re-establishing also , when ever the tcp/ip link established again that time the communication should be using in that link only. This is accomplished by deploying the RT vi as execuatbale file. I made some logic regards to the above said logic , bur it was not working as much I expected.
I request you to go through the attached two VI's and let me know , what I did wrong in that,
Please do the needful.
Attachments:
TCP_Serial_Host.vi 33 KB
TCP_Serial_RT.vi 41 KBeven i am new to this topic and i am trying to get familiar with these protocols
refer to tcp server/client examples in labview examples -
Safety of MS Sharing on LAN over TCP/IP via NetBIOS and/or Direct SMB
Shalini Sampath Kumar at http://answers.microsoft.com/en-us/windows/forum/windows_7-security/ suggested I post this question over
here:
What is the safest recommended way to set up MS File and Printer Sharing on a LAN with both Windows 7 Pro and XP Pro machines? Does "Direct hosting of SMB over TCP/IP," help? What about setting a "Scope ID" (or did that go out
with Windows NT)?
Background: I've been trained to be paranoid about NetBIOS over TCP/IP. Right now I have only XP Pro machines on my peer-to-peer workgroup LAN (behind a NAT router and with Simple File Sharing turned off), on which File and Printer Sharing has been
unbound from TCP/IP and bound to NetBEUI instead, so I feel fairly safe. Port scanning by ShieldsUp doesn't see any ports through the router, open or closed -- in other words, it appears to be "stealthed," for what that's worth. With
NetBIOS disabled on all computers inside the LAN, however, can I perform a valid test of what will happen when File and Printer Sharing is re-bound to TCP/IP?
My New Problem: I'm planning to add Window 7 Pro machines, for which NetBEUI isn't an option, and then to transition entirely to Win7 before XP goes off extended support in April. I will still use a peer-to-peer architecture with password-protected
sharing turned on (no HomeGroup). It appears that I can still get rid of NetBIOS (and WINS) in favor of "Direct hosting of SMB over TCP/IP," which sounds safer. Apparently then only port 445 will be vulnerable instead of ports 137-139.
In any case I want to do everything I can to protect my file-sharing port(s) from the Internet (e.g., from anyone who might break into my LAN either by making a wireless connection or by hacking the router itself). Can anybody give a clear set of steps
to change sharing from NetBIOS (which I would like to disable entirely) to direct hosting of SMB and to verify that I'm protected as well as possible?
I will have to completely revamp the network-file-sharing configuration of my XP machines as soon as the first Win7 machine goes on line (and possibly tweak the configuration of Win7 as well), perhaps as early as this week. I want to do this in the way that
maximizes security to the extent possible. Thanks in advance more details and guidance on this topic! -- JCW2
P.S. -- These computers are all laptops and will be used away from my home LAN -- another reason for paranoia about File and Printer Sharing. I realize that Windows 7 provides an easy way to disable F&PS by selecting any new network location as
"public," but XP does not (as far as I know). Fixing that will take more effort and be harder to remember... -- JCW2Removing the NetBIOS transport has several advantages compared to NetBIOS over TCP, you can find detailed infromation in the following KB
Direct hosting of SMB over TCP/IP
http://support.microsoft.com/kb/204279/en-us
Yolanda
TechNet Community Support
Hi again -- I think I'm slowly catching up with you. Following from my previous message...
Somebody on another forum mentioned creating "Hosts" files on each computer to substitute for the DNS server that I don't have on my workgroup. This is intriguing if I can figure out how to set it up. (I've heard it said that taking control of
your "Hosts" file is a good safety precaution anyhow, since it is a frequent target of hackers trying to divert legitimate Web requests to their own malicious sites.) Does anybody have tips and/or references that would help me accomplish the name resolution
there?
Finally, what functionality do I really lose by going the Direct-Hosting-of-SMB-with-Hosts-file (or drive mapping) route as opposed to using NetBIOS over TCP/IP? Granted, any new machine added to the network would also have to be added to all the "Hosts"
files (or mapped to a new drive letter) on each machine; but given that I already have to add it to the MAC filter and assign it a DHCP reservation in my router, this isn't a heavy burden for something that doesn't happen often. Would everything then
work the same as if NetBIOS were providing the name resolution?
One missing piece that I see so far -- it's not obvious how this same trick would apply to printer sharing (although I'm not using that feature right now anyhow). Could this be handled seamlessly through the "Hosts" file as well?
Thanks and Best Regards to All -- JCW2 -
Problem with serialized objects and JWS
My JWS launched application fails when loading a serialized object that has been instatiated from a class not contained in the signed jar-file. Does anyone know why this happens and if there is some workaround for the problem?
Where is the class contained then?
-
OID and binding java serialized object
Hi there,
How are you doing? I am trying to bind a serialized java object to a name in Oracle Internet Diectory (oid) using JNDI.
it gives me an errror.
"OperationNotSupported LDAPA error 53: Unwilling to perform:
I have directory manager 2.1.1 and JNDI 1.2.1
I arrpeciate any clue and/or help
Thanks
nullHello:
Although OID supports calls from JNDI, the JNDI schema for storing JAVA serialized objects is not yet a standard part of the OID schema. This is easy to remedy. Go to javasoft.sun.com and download the JNDI schema for java serialized objects and load the attributes and objectclasses into OID from the ldif files provided at this web site. . Make sure the attributes are loaded before the objectclasses.
Once this schema is loaded this problem should go away
Use the ldapmodify command line tool to add the schema items from the ldif file.
Let me know if you need further assistance setting this up. A future version of OID will contain these schema items standard.
Thanks,
Jay
null -
Saving and loading serialized objects (StreamCorruptedException)
Hello,
I am relatively new to Serialization (coming to that, a bit new to Java too) and I am having a problem with the following:
I am saving a number of serialized objects (all of the same class) in a file using the following way (the method is called multiple times to save a list of TeamMember objects):
Note: TeamMember is a custom class.
public void addTeamMember(TeamMember p) {
outputStream = new ObjectOutputStream( new FileOutputStream( "team.dat", true ) );
outputStream.writeObject( p );
outputStream.flush();
outputStream.close();
outputStream = null;
}Then I'm trying to retrieve the objects from the file and display them. The method used is the following (it will loop through the file until found or it throws an EOFException. Is using the EOFException good practice to search through the entire file?):
public TeamMember getTeamMember(String id) {
TeamMember currentMember = null;
try {
boolean found = false;
inputStream = new ObjectInputStream( new FileInputStream( "team.dat" ) );
while ( !found ) {
currentMember = (TeamMember)inputStream.readObject();
if ( currentMember.getId().equals( id ) )
found = true;
} // end while
closeInputFile();
return currentMember;
} // end try
catch ( EOFException e ) { // end of file reached
closeInputFile();
return null;
} // end catch
catch ( IOException e ) {
closeInputFile();
System.err.println( e.getMessage() );
return null;
} // end catch
}Now as a test, I am adding 3 members with IDs 1, 2 and 3 respectively. Then I am calling getTeamMember three times with the different IDs. With ID "1", it works fine. When I give it ID 2, it gives an IOException with message "StreamCorruptedException: invalid type code: AC".
While tracing the program, I've seen that it always gives me that error when reading past the first object saved in the file.
Am I saving the objects in a wrong way, or reading them is done incorrectly?
Any help is much appreciated.
I hope I was clear enough, and that I posted in the correct forum.
Thanks in advance.
Andrew.If that is so, might you hint me for a work around?
I want to append objects in a single file, then be able to find and read an object from the file.
Thanks again.
Andrew -
Aperture forgets it license and asks me for the serial number over and over again
Hi,
This is getting ridiculous to the point where I'm thinking of just ditching Aperture. It's continually forgetting is license and asking me for the serial number over and over again. I have the original serial number and an upgrade number when I upgraded to v3, but right now, it's not accepting either of them. What's going on and how do I fix it permanently?
Thanks,
RobRob, have you upgraded to Aperture 3.4.3? This is supposed to have fixed the serial number problem:
http://support.apple.com/kb/DL1610
About Aperture 3.4.3
Addresses an issue that could cause a licensed copy of Aperture to prompt for a serial number with each launch
Be sure to enter the serial number, when you are logged in from an account with Administrator priveleges - otherwise can it not be stored.
Aperture is installed for all users on your mac, so the serial number is written to the system library, not the user library, and this requires read/write access for administrators. Do you enter your serial number using an administrator account?
When did this start? Have you migrated your system from from another mac? Then you still may have an older ProAppSystemID file or Aperture cannot write to the System Library.
To stop Aperture asking for the serial number, first check, if you still have an old file "ProAppSystemID" in your System Library.
Quit Aperture.
Go to your MacintoshHD and open the folder "Library", then "Application Support", then "ProApps".
Remove the File "ProAppsSystemID" to the Desktop, if it exist and restart Aperture.
Reenter your serial number, hopefully for the last time.
Sometimes Aperture writes this file to a temporary directory, when it cannot write to the Library. If the above does not work, look at the temporary directory /tmp
Use the Finder's "Go" menu
Go > Got to folder and enter /tmp into the textfield. If you see the file there, move it to its proper location.
In this case you may want to repair the permissions on your system drive; you can do this using the "First Aid" tools in "Disk Utility" (located in Applications > Utilities)
Regards
Léonie -
Serialized Objects and Servlets
I'm having a lot of trouble accessing a serialized object and displaying it in a servlet. I get the following exception:
java.io.StreamCorruptedException: Type code out of range, is -84
Can anyone help me out here?OK... here's some of the code I'm using...
public Object readObject()
throws IOException, ClassNotFoundException
oin = new ObjectInputStream(fin);
Object obj = oin.readObject();
oin.close();
return obj;
public void writeObject(Object data)
throws IOException
oout = new ObjectOutputStream(fout);
oout.writeObject(data);
oout.close();
Essentially, my servlet creates and instance of an ObjectManager class. This ObjectManager then tries to execute the readObject method above.
The whole process comes to a grinding halt at this point:
Object obj = oin.readObject();
I think this problem has to do with the way that I'm trying to access the file to which I have serialized my object. The problem is that I can't think of any other way to do it. Here's how I am currently referencing the file that holds my serialized object:
File theFile = new File("Serialized.dat");
FileInputStream fin = new FileInputStream(theFile);
I've never attempted anything like this before and I suspect I'm way off in my approach. I really appreciate your willingness to help me out.
Maybe you are looking for
-
Hi - We use the AP Trial Balance Report as a supporting schedule to reconcile our General Ledger AP Creditor Control Account against. Ordinarily we would use the total remaining amount at the end of the report (which has historically balanced to the
-
How do i delete my credit card information from my account while keeping the account ?
I want to delete my credit card information from my APPLE ID but there is no NONE button, how do i do this ?!?!?
-
Itunes will not sync songs incorrectly "they cannot be played on this ipod"
Recently I had a loptop crash, this required a rebuild and a reinstall of itunes. I resynced the ipod touch and promtly lost most songs! Now I am unable to sync all the songs back even after restoring them to the playlist (from backups); some songs f
-
Package from AUR failed to install after doing many steps, how to rm?
How can I see what files have been left on my hard drive after a package failed to install. I can't pacman -Rsu the package because it didnt install, but now i got some other packages that i don't need then. and probably some other stuff while the pa
-
Protecting Photos in IWeb Webpage
Is there additional ways to protect your photos from being downloaded from your webpage other than the Password Inspector button?