CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: TCP/IP

  1. #1
    Join Date
    Mar 1999
    Posts
    112

    TCP/IP

    Hi
    I build an APPLET program that work with TCP/IP
    i success to connect a server and i success to
    send data to the server but the problem is
    to recv text from the server only when i close
    the server i get the data he send me.
    The server send me data and i don't get the data
    until i close the server and then i get all the data he send me.

    here is the Thread that recv the data

    class RecvThread extends Thread
    {
    Socket socket = null;
    BufferedReader in = null;
    String info;
    TextArea text;

    RecvThread(Socket s,BufferedReader i,TextArea t)
    {
    this.socket = s;
    this.in = i;
    this.text = t;
    }
    public void run()
    {
    try
    {
    while ((info=in.readLine())!=null)
    {
    text.setText(text.getText() + " " + info);
    }
    }
    catch (IOException e)
    {
    }
    }
    }



    Why ???
    Thak You
    i will rate.


  2. #2
    Join Date
    May 1999
    Location
    Pune, MH, India.
    Posts
    453

    Re: TCP/IP

    There are two possibilities...

    1. If you have developed server yourself and you have used buffered-stream for it, you should flush it after out-putting a line.

    2. If the server is developed by someone else or doesn't use buffered-stream, it might not be sending line separator (\n), that's why readLine method keeps waiting for it. In this case try reading the data in bytes and then whatever you get, convert it to string as per your needs.

    - UnicMan
    http://members.tripod.com/unicman

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured