Solved

java client receive a packet from delphi server

Posted on 2003-10-26
3
242 Views
Last Modified: 2010-03-31
I want to receive a packet from server.It's seemed that readObject() cann't be used,when server is a java server,it can get the right class,but   when server is a delphi server,it shows "not a serilizable
inputstream",how could i get packet from delphi server?
0
Comment
Question by:lingwangbochen
  • 2
3 Comments
 
LVL 15

Expert Comment

by:jimmack
ID: 9625491
If you use readObject(), then your client is expecting a Java object to come across the link (including information about the methods, attributes etc.).

You say that you want to receive a "packet".  What is the format of the packet?

Can you read it as a byte[] sequence and reconstruct it on the Java client into an object there?
0
 

Author Comment

by:lingwangbochen
ID: 9625603
the "packet" include the seqno of the packet,length of the packet,content of the packet...
for example:
   public int plength;
   int commandid;
   int seqno;
   int bindtype;
   String user;                      //can change to another content
   String passwd;                 //can changeable
it is sended from delphi using" SendBuf " function,
I can receive a char use read() or read(char[],int,int) of Class java.io.BufferedReader,i don't know how to reconstruct it and
 the packet is changeable,so i think read as object perhaps be simple. i only receive some char now.Could you help me?
 
0
 
LVL 15

Accepted Solution

by:
jimmack earned 125 total points
ID: 9625651
You would probably be better using a DataInputStream instead of a BufferedReader.  This would allow you to use methods like readInt(), readUTF() etc.

(readUTF() is for reading Strings).

If the packet contains different data, is there a way to determine the format of the data that is expected across the link (like an identifier or something).

In this particular case, you need a class to store the attributes you have described, then you could read them from the stream using:

MyObject myObj = new MyObject();
DataInputStream dis = new DataInputStream(  < your raw input stream here > );
myObj.setPlength = dis.readInt();
myObj.setCommandid = dis.readInt();
myObj.setSeqno = dis.readInt();
myObj.setBindtype = dis.readInt();
myObj.setUser = dis.readUTF();
myObj.setpasswd = dis.readUTF();

0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
varialbe initialization 11 32
javap not working 8 43
Android development question 2 34
String array comparison 4 32
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now