f



Java client connected to non-Java server problems

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?
0
11/10/2004 2:22:04 AM
comp.lang.java.programmer 52714 articles. 1 followers. Post Follow

6 Replies
531 Views

Similar Articles

[PageSpeed] 29

illusionistx@gmail.com (Illusionistx) wrote in message news:<cbfebe80.0411091822.7f30c92d@posting.google.com>...
> 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-   ><>
0
joeking (137)
11/10/2004 1:42:40 PM
FISH wrote:

> 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


0
chris.uppal (3980)
11/10/2004 2:10:58 PM
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){}
		}
	}
0
11/10/2004 9:34:22 PM
Unless the VB server knows about Unicode it would make more sense to use 
Input/OutputStreams rather than Readers & Writers.

0
11/11/2004 4:32:09 AM
Thanks Esmond, but that made no sense, and no difference. I got it all
worked out now thanks all.
0
11/11/2004 8:28:56 PM
illusionistx@gmail.com (Illusionistx) writes:

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

So what was the problem, and solution?

--KW 8-)
-- 
Keith Wansbrough <kw217@cl.cam.ac.uk>
http://www.cl.cam.ac.uk/users/kw217/
University of Cambridge Computer Laboratory.
0
kw217 (12)
11/12/2004 11:37:53 AM
Reply: