steps foro writting clint programming

steps for writting clint program
1) open a socket
    socket clint=new socket(Server_address,port id);
this statement creates a socket for clint computer.while creating socket we need to provide IP address or domain name of the computer where server program executes and the port number in which server listens to the client.

2) open an input stream and output stream to the socket
        Scanner ins= new Scanner(clint.getInputStream());
        printwriter outs= new PrintWriter(clint.getOutputStream(),true);
the first statement gets inputs stream class of clints socket and open scanner on it.Simillarly the second statements gets output stream of clints soket and open printWriter on it.

3) read from and write to the socket stream
        rs=ins.nextLine();
        outs.println(s);
the first statement reads a line from clint's socket and puts it in variable 'rs' and the second statement write the value of string variable 'ss' into clint's socket.

4) close the statement
        ins.close();
        outs.close();
once I/O is completed,above statement are used to input stream and output stream of clint's socket.

5) close the streams
        clint.close();
we use this statement to close the connection between  server and computer.

Comments

Popular posts from this blog

thread

psychology two questions n their answer