ATM_ISO8583 (1)

ere i am adding all of my Java coding samples for reference.  This will help me to recall , give me your comments if any wrong code presented, which will help to develop my knowledge in Java .

Servlet Socket Program

TCP Server Sample

import java.io.*;
import java.net.*;

class servertcp extends Thread


public static void main(String argv[]) throws Exception


int port = 5000;
ServerSocket Server = new ServerSocket (port);
System.out.println (“TCPServer Waiting for client on port ” + port);
int id = 0;
Socket connected = Server.accept();
ClientServiceThread cliThread = new ClientServiceThread(connected, id++);

class ClientServiceThread extends Thread {
Socket clientSocket;
int clientID = -1;
boolean running = true;

ClientServiceThread(Socket s, int i) {
clientSocket = s;
clientID = i;

public void run()
System.out.println (“TCPServer Waiting for client on port 5000″);
String fromclient;
String toclient;
while(true) {
//System.out.println( ” THE CLIENT”+” “+connected.getInetAddress() +”:”+connected.getPort()+” IS CONNECTED “);
System.out.println(“Connected with client ‘IPAdress’ :” +clientSocket.getInetAddress());
BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in));
BufferedReader inFromClient = new BufferedReader(new InputStreamReader (clientSocket.getInputStream()));
PrintWriter outToClient = new    PrintWriter(clientSocket.getOutputStream(),true);
String temp = “”;
while (true) {
System.out.println(“Press ‘X’ to Quit or Press ‘Enter’ to send the file:”);
toclient = inFromUser.readLine();
FileInputStream fstream = new FileInputStream(“C://TCPIP/sample.txt”);
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
while ((strLine = br.readLine()) != null)   {
temp =temp + strLine +”|”;
if ( toclient.equalsIgnoreCase(“x”)) {
} else {
System.out.println(“File Send to the Client”);
fromclient = inFromClient.readLine();
if ( fromclient.equalsIgnoreCase(“x”)) {
}else {
System.out.println( “RECIEVED:” + fromclient );
}catch(Exception e)
System.out.println(“Error in MultiThreading”);


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Blog at WordPress.com.

%d bloggers like this: