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
Solved

java client receive a packet from delphi server

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

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

Suggested Solutions

Title # Comments Views Activity
How to execute a Python program and gather return output in Java 2 40
Notify sent to other threads in Java 9 33
Java basic valueOf question 1 29
collection output issue 9 36
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…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

839 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