server test Java source code
#1

Code:
import java.util.*;
import java.io.*;
import java.net.*;

public class servertest
{
    final static int SERVER_PORT = 8001;
    public static void main(String a[])
    {
        Server server;
        String creq,sr;
        BufferedReader reader,read;
        PrintWriter writer,write;

        server = new Server(SERVER_PORT);
        reader = new BufferedReader(new InputStreamReader(server.in));
        writer = new PrintWriter(new OutputStreamWriter(server.out),true);
        read = new BufferedReader(new InputStreamReader(System.in));
        write = new PrintWriter(new OutputStreamWriter(System.out),true);

        writer.println("Java Test Server " + new Date());

        while(true)
        {
            try {

                creq = reader.readLine();
                System.out.println("Client says : " + creq);
                sr = read.readLine();
                writer.println(sr);
                /*if(creq.equals("hai"))
                    writer.println("i am venkatesh");*/
                if(creq.equals("quit"))
                    System.exit(0);
            }catch(IOException e) {
                System.out.println("Exception caught");
            }
        }
    }
}

class Server
{
    private ServerSocket server;
    private Socket socket;

    public InputStream in;
    public OutputStream out;

    public Server(int port)
    {
        try {
            server = new ServerSocket(port);
            System.out.println("ServerSocket before accept : "+server);
            System.out.println("Java test server on-line");

            socket = server.accept();
            System.out.println("ServerSocket after accept : "+server);

            in = socket.getInputStream();
            out = socket.getOutputStream();
        }catch(IOException e) {
            System.out.println("caught server constructor");
        }
    }
}
Reply

Important Note..!

If you are not satisfied with above reply ,..Please

ASK HERE

So that we will collect data for you and will made reply to the request....OR try below "QUICK REPLY" box to add a reply to this page
Popular Searches: hospital management system source code in java server page, java server pagesseminar topic, quiz test source code in java, news server java source code, java test app, puthukavithai tharabharathi tamumil writer, tomcat java server,

[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Possibly Related Threads...
Thread Author Replies Views Last Post
  Simple Key Events Java source code smart paper boy 3 3,601 07-02-2017, 03:41 PM
Last Post: NARESHLAFOOT
  Window Events Java source code smart paper boy 1 3,674 02-03-2012, 10:48 AM
Last Post: seminar paper
  Inter net banking java source code smart paper boy 3 5,951 01-03-2012, 11:24 AM
Last Post: seminar paper
  UDP server java source code smart paper boy 1 3,814 05-01-2012, 05:50 PM
Last Post: jeslinapeter
  UDP client Java source code smart paper boy 2 3,678 12-12-2011, 09:56 AM
Last Post: seminar addict
  Text Demo Java source code smart paper boy 0 2,076 30-08-2011, 12:44 PM
Last Post: smart paper boy
  Text Area Demo Java source code smart paper boy 0 2,083 30-08-2011, 12:44 PM
Last Post: smart paper boy
  Servlet Database Java source code smart paper boy 0 2,458 30-08-2011, 12:42 PM
Last Post: smart paper boy
  Ser To App java source code smart paper boy 0 1,677 30-08-2011, 12:39 PM
Last Post: smart paper boy
  SB Demo java source code smart paper boy 0 1,538 30-08-2011, 12:38 PM
Last Post: smart paper boy

Forum Jump: