How To Create A Client Server Application In Java Using Network Programming
Rate this article
0 out of 5
In this tutorial we will show you how to develop a client server application in java using network programming. After viewing the video tutorial, download the source code and try to modify the code so as to get a feel of what is learned in this video tutorial.




Source Code
Document1.java

/*

 * To change this template, choose Tools | Templates

 * and open the template in the editor.

 */

 

package clientsocket;

 

import java.io.IOException;

import java.io.ObjectInputStream;

import java.io.ObjectOutputStream;

import java.lang.ClassNotFoundException;

import java.net.InetAddress;

import java.net.Socket;

import java.net.UnknownHostException;

 

 

public class Main {

 

    /**

     * @param args the command line arguments

     */

    public static void main(String[] args) {

       try

       {

        InetAddress host = InetAddress.getLocalHost();

        Socket socket = new Socket(host.getHostName(),7777);

        ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());

        oos.writeObject("Hellow there");

 

        ObjectInputStream ois =new ObjectInputStream(socket.getInputStream());

        String strMessage = (String)ois.readObject();

        System.out.println("Message:" + strMessage);

        oos.close();

        ois.close();

 

       }

       catch(UnknownHostException e)

       {

           e.printStackTrace();

       }

       catch(IOException e)

       {

           e.printStackTrace();

       }

       catch(ClassNotFoundException e)

       {

           e.printStackTrace();

       }

 

    }

 

}



Source Code

About The Author
KTS Training

KTS InfoTech Training division offers various short-term programming courses for Students and Professionals who are looking for a bright career in the field of Software development.

The programming video tutorials presented in this web site are taken from some of the training sessions conducted by KTS InfoTech.

You can also learn the Programming packages through Internet directly form our English Speaking Technical experts at an affordable rate.

For more details click here and submit your training requirements.



Number Of articles Posted
60
Number Of Messages Posted
3
Joined Date
14/11/2012
   
Author
Messages
Posted:
Post Your Comments
Name (Max 50 Chars)
Comments

 
   
TekTipsDownload
GateExam
Academic Projects
TekTipsExperts
Android