Java client connected to non-Java server problems

I

Illusionistx

I'm trying to connect a java client application to a chat server i
wrote in vb. i know the server works, and i know the client works(when
used with a java server), but when i use the vb server and the java
client, the client doesn't get the data sent from the server. But then
when i send back from the client to the server, then what i sent from
the server shows up, so it's like the buffer isn't getting read or
flushed when i send from the server. What is the best approach i
should take on this?
 
F

FISH

I'm trying to connect a java client application to a chat server i
wrote in vb. i know the server works, and i know the client works(when
used with a java server), but when i use the vb server and the java
client, the client doesn't get the data sent from the server. But then
when i send back from the client to the server, then what i sent from
the server shows up, so it's like the buffer isn't getting read or
flushed when i send from the server. What is the best approach i
should take on this?



Firstly, be absolutely certain you know whether it's the client or the
server at fault. It's very easy to assume a particular bit of software
is blameless - you need an independent test. Telnet to the server and,
as best you can, try to use it 'manually'. This will tell you whether
the server is sending out data. If it is, the fault is likely in your
Java client. If it isn't, the fault is probably in your VB server.

Are the reading and writing parts running in separate threads? It
sounds like your code isn't accepting/processing incoming messages until
after it sends an outgoing message. (You haven't done something silly,
like put both the accepting and sending code in an event handler tied
to the SEND button on your client UI... have you? ;-)


-FISH- ><>
 
C

Chris Uppal

FISH said:
Firstly, be absolutely certain you know whether it's the client or the
server at fault. It's very easy to assume a particular bit of software
is blameless - you need an independent test. Telnet to the server and
[...]

This is very sound advice, but I'd suggest that rather than using Telnet, a
network sniffer like ethereal

www.ethereal.com/

would be better still. If you are transmitting data over network at all (and
who isn't these days) then sooner or later you will have to learn to make at
least simple use of tools like ethereal -- and once you have learned you'll
wonder why you ever tried to do without them in the first place.

-- chris
 
I

Illusionistx

Yes I'm absolutely sure that the fault lies within the java client, as
i wrote the server long ago and works perfectly with vb client. and
the client works fine to, with a java server. I am using both a
buffered reader and a buffered writer... here is what it looks like
....in constructor...
try{
s = new Socket("127.0.0.1", 1053);
br = new BufferedReader(new InputStreamReader(s.getInputStream()));
bw = new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
Thread th;
th = new Thread(this);
th.start();
}catch(Exception e){}
....

public void run(){
while (true){
try{
list.addItem(br.readLine());
}catch (Exception h){}
}
}


public void actionPerformed(ActionEvent ae){
if(ae.getSource().equals(exitBut))
System.exit(0);
else{
try{
bw.write(text.getText());
bw.newLine();
bw.flush();
text.setText("");
}catch(Exception m){}
}
}
 
E

Esmond Pitt

Unless the VB server knows about Unicode it would make more sense to use
Input/OutputStreams rather than Readers & Writers.
 
I

Illusionistx

Thanks Esmond, but that made no sense, and no difference. I got it all
worked out now thanks all.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top