Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: find the error

  1. #1
    Junior Member
    Join Date
    Apr 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default find the error

    import java.net.*;
    import java.io.*;
    public class myclient
    {
    Socket s;
    DataInputStream din;
    DataOutputStream dout;
    myclient()
    {
    try
    {
    s=new Socket("Localhost",13);
    System.out.println(s);
    din=new DataInputStream(s.getInputStream());
    dout=new DataOutputStream(s.getOutputStream());
    clientchat();
    }
    catch(Exception e)
    {
    System.out.println(e);
    }
    }
    public void clientchat() throws IOException
    {
    BuffferedReader br= new BufferedReader(new InputStreamReader(System.in));
    String s1;
    do
    {
    s1=br.readLine();
    dout.writeUTF(s1);
    dout.flush();
    System.out.println("Server message"+din.readUTF());
    }
    while(!s1.equals("stop"));
    }
    public static void main(String...g)
    {
    new myclient();
    }
    }


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: find the error

    Please use code tags when posting code.
    If you have an error also include the full text of the error message with your code and question.

  3. #3
    Junior Member
    Join Date
    Nov 2011
    Location
    Aarhus, Denmark
    Posts
    28
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: find the error

    Your program tries to connect to a TCP socket on localhost using port 13. Does anything actually run to accept connections on port 13?

    If you are trying to make 2 of your programs talk together one of them must open a ServerSocket to listen for connections.

    Rolf

Similar Threads

  1. Please Help me Find the Error
    By jugalrockz in forum What's Wrong With My Code?
    Replies: 7
    Last Post: January 18th, 2012, 02:31 AM
  2. help to find the error of coding
    By arunjib in forum What's Wrong With My Code?
    Replies: 8
    Last Post: November 27th, 2011, 11:28 AM
  3. Cannot find symbol ERROR
    By yacek in forum What's Wrong With My Code?
    Replies: 8
    Last Post: October 21st, 2011, 11:39 PM
  4. error :cannot find symbol
    By iswan in forum AWT / Java Swing
    Replies: 1
    Last Post: October 1st, 2011, 08:26 AM
  5. Need help, cannot find error
    By Imeri0n in forum What's Wrong With My Code?
    Replies: 13
    Last Post: December 5th, 2010, 05:26 PM