?
Solved

java client receive a packet from delphi server

Posted on 2003-10-26
3
Medium Priority
?
257 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month7 days, 23 hours left to enroll

765 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