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 4 of 4

Thread: its urgent

  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post its urgent

    i want to send data from one computer to another using socket.how can i start it any idea.please help me.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,264
    Thanks
    176
    Thanked 821 Times in 764 Posts
    Blog Entries
    5

    Default Re: its urgent

    Did you try google? One of the top hits: All About Sockets

  3. #3
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 287 Times in 225 Posts
    Blog Entries
    4

    Default Re: its urgent

    Moved to - Java Networking - Java Programming Forums

    Do a search on the forums for Socket or client server. This has been answered before.
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

    Looking for a Java job? Visit - Java Programming Careers

  4. #4
    Junior Member
    Join Date
    Nov 2010
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: its urgent

    /*yes i have solved the socket programe.but now my problem is to send string to server from client

    my client programe is*/

    import java.net.*;
    import java.io.*;
    import java.util.*;
    public class Client12
    {
    public static void main(String args[])
    {
    try
    {
    Client12 world=new Client12();


    }catch(IOException e){}



    }

    static final public int PortNumber =8000;
    public Client12()throws IOException
    {
    Scanner as=new Scanner(System.in);
    Socket S=new Socket("127.0.0.1",PortNumber);
    DataInputStream fromserver=new DataInputStream(S.getInputStream());
    //BufferedReader BR=new BufferedReader(R);
    DataOutputStream toserver=new DataOutputStream(S.getOutputStream());
    //int rad=0;
    /*for(
    {
    System.out.print("enter=");
    int rad=as.nextInt();
    System.out.print("you have entered=="+rad);
    toserver.writeInt(rad);
    int r=fromserver.readInt();


    fromserver.flash();

    System.out.println("\nreply From Server:\n"+r);
    }*/
    //here is my String

    String s="sdf".trim();

    OutputStreamWriter out
    = new OutputStreamWriter(S.getOutputStream( ));

    \\here im sending the STRING
    out.write(s);


    }

    }
    //it doesnt show any error.but when i run the server it doesnt print the STRING which i send from client

    //my server programe is bellow
    //---------------------------------------------------------------------------------------------------------------------------

    import java.net.*;
    import java.io.*;
    import java.util.*;
    import java.lang.Object;
    public class Server12
    {
    public static void main(String args[])
    {
    try
    {
    Server12 world=new Server12();


    }catch(IOException e){}



    }

    static final public int PortNumber =8000;
    public Server12()throws IOException
    {
    ServerSocket SS=new ServerSocket(PortNumber);
    Socket S=SS.accept();
    while(true)
    {
    System.out.println("\nWaiting....Run the Client Program");
    // Socket S=SS.accept();
    System.out.println("\nClient found and Message Shown");
    //OutputStreamWriter OSW=new OutputStreamWriter(S.getOutputStream());
    ObjectInputStream fromclient;
    fromclient =new ObjectInputStream(S.getInputStream());
    DataOutputStream toclient=new DataOutputStream(S.getOutputStream());




    Object sd=fromclient.readLine();
    System.out.print("sdf"+sd);


    String Msg="Current Date And Time on Server is:"+new Date()+"\n";
    //OSW.write(Msg);
    // OSW.close();

    }

    }
    }

    /*please help me.
    i cant understand why the programe doesnt response for String transmition.*/
    Last edited by talha07; January 22nd, 2011 at 12:59 PM.

Similar Threads

  1. PLEASE HELP ME .. IS URGENT
    By chela02 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 18th, 2010, 04:37 PM
  2. Help URGENT
    By javfifed in forum Java Theory & Questions
    Replies: 7
    Last Post: July 4th, 2010, 11:16 AM
  3. Urgent!!!!!!!!!!!!!!!!
    By dinesh03188 in forum JDBC & Databases
    Replies: 3
    Last Post: May 14th, 2010, 01:38 AM
  4. Urgent Help Please :)
    By Jamie94 in forum Algorithms & Recursion
    Replies: 0
    Last Post: May 12th, 2010, 06:34 AM
  5. Replies: 1
    Last Post: May 4th, 2009, 06:30 AM