1 Replies - 3401 Views - Last Post: 28 January 2012 - 02:46 PM

#1 bita   User is offline

  • D.I.C Head

Reputation: 3
  • View blog
  • Posts: 190
  • Joined: 21-April 09

client/server socket programming

Posted 28 January 2012 - 09:30 AM

Hi all,
I'm completely new to network programming in java. I've got a code about Client/Server Interaction with Stream Socket Connections, it consists of server and client code with their own clienttest and servertest to implement. The problem is that I don't know how to relate these two client and server to each other, I can say that I almost understand what the code is about and how it works, but I'm confused about how to relate them to each other.
here is the demo of the code:

public class Client extends JFrame 
{
.
.
.
public Client( String host )
   {
   .
   .
   .
   }
}



public class ClientTest 
{
   public static void main( String args[] )
   {
      Client application; // declare client application

      // if no command line args
      if ( args.length == 0 )
         application = new Client( "127.0.0.1" ); // connect to localhost
      else
         application = new Client( args[ 0 ] ); // use args to connect

      application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
      application.runClient(); // run client application
   } // end main
} // end class ClientTest



public class Server extends JFrame 
{
.
.
.
public Server()
   {
   .
   .
   .
   }
}




public class ServerTest
{
   public static void main( String args[] )
   {
      Server application = new Server(); // create server
      application.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
      application.runServer(); // run server application
   } // end main
} // end class ServerTest



This was the out line the code.
The final result should be like the file attached, but it doesn't make any connection.
the first image is what it should be during running the code.

Any help would really be appreciated.
Sophia.

Attached File(s)

  • Attached File  j2ee.bmp (203.18K)
    Number of downloads: 88


Is This A Good Question/Topic? 0
  • +

Replies To: client/server socket programming

#2 blackcompe   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1159
  • View blog
  • Posts: 2,547
  • Joined: 05-May 05

Re: client/server socket programming

Posted 28 January 2012 - 02:46 PM

Well, the class isn't going to complete itself. What tutorials have you looked at? The Java tutorials is a good place to start.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1