Solved

java client receive a packet from delphi server

Posted on 2003-10-26
3
235 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
strCount chalenge 3 51
topping2 challenge 13 62
wordappend challenge 8 88
Systems talking to each other 5 110
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

746 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