Java client connected to non-Java server problems

Discussion in 'Java' started by Illusionistx, Nov 10, 2004.

  1. Illusionistx

    Illusionistx Guest

    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?
    Illusionistx, Nov 10, 2004
    #1
    1. Advertising

  2. Illusionistx

    FISH Guest

    (Illusionistx) wrote in message news:<>...
    > 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- ><>
    FISH, Nov 10, 2004
    #2
    1. Advertising

  3. Illusionistx

    Chris Uppal Guest

    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
    Chris Uppal, Nov 10, 2004
    #3
  4. Illusionistx

    Illusionistx Guest

    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){}
    }
    }
    Illusionistx, Nov 10, 2004
    #4
  5. Illusionistx

    Esmond Pitt Guest

    Unless the VB server knows about Unicode it would make more sense to use
    Input/OutputStreams rather than Readers & Writers.
    Esmond Pitt, Nov 11, 2004
    #5
  6. Illusionistx

    Illusionistx Guest

    Thanks Esmond, but that made no sense, and no difference. I got it all
    worked out now thanks all.
    Illusionistx, Nov 11, 2004
    #6
  7. (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 :cool:
    --
    Keith Wansbrough <>
    http://www.cl.cam.ac.uk/users/kw217/
    University of Cambridge Computer Laboratory.
    Keith Wansbrough, Nov 12, 2004
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Danny M
    Replies:
    0
    Views:
    401
    Danny M
    Feb 3, 2004
  2. Dundonald
    Replies:
    2
    Views:
    393
    Steve Horsley
    Mar 15, 2005
  3. Irmen de Jong
    Replies:
    0
    Views:
    684
    Irmen de Jong
    Jun 25, 2003
  4. Peter Hansen
    Replies:
    1
    Views:
    701
    Amos Joshua
    Jun 29, 2003
  5. Replies:
    5
    Views:
    2,457
    _JusSx_
    Feb 28, 2010
Loading...

Share This Page