Here is the scenario :

Client Side : pack and send message to server using TCP/IP
Receive the response message from server
unpack the Response message

ServerSide :
Receive the packed message sent by Client using TCP/IP
pack and Send a Response message to Client


Server is able to receive the message sent by client and will be able to reach the code block to send response only when i comment the receive_PackedResponseData.readLine().getBytes()) in client code (But i'm not able to see the response on client side.). If its uncommented then server will not even reach the block of code to send response.

I'm not able to understand whats wrong in it. Looking for your help.

Client Code :
Code:
                        BufferedOutputStream outStream = null;
			BufferedReader receive_PackedResponseData = null;			

			  /**  Construct Request Message */
                        GenericPackager packager = new GenericPackager("basic.xml");
                        ISOMsg isoMsg = new ISOMsg();
			isoMsg.setPackager(packager);
                        isoMsg.setMTI("0300");
			//set all the required Data Elements

                       byte[]  send_PackedRequestData = isoMsg.pack();

                       Socket connection = new Socket("localhost", 8180);
			if (connection.isConnected()) {
				outStream = new BufferedOutputStream(
						connection.getOutputStream());
				outStream.write(send_PackedRequestData);
				outStream.flush();
				System.out.println("-----Request sent to server---");
				System.out.println(ISOUtil.hexString(send_PackedRequestData));
			}

			/** Receive Response */

			if (connection.isConnected()) {
				receive_PackedResponseData = new BufferedReader(
						new InputStreamReader(connection.getInputStream()));
				System.out.println("-- RESPONSE recieved---");
				System.out.println(receive_PackedResponseData);
				// System.out.println("Response : "+ISOUtil.hexString(receive_PackedResponseData.readLine().getBytes()));				
			}

			receive_PackedResponseData.close();
			outStream.close();
			connection.close();

Server Code :

Code:
 BufferedReader receive_PackedRequestData =null;
		BufferedOutputStream outStream=null;
        
		/** Establish connection */
		ServerSocket Server = new ServerSocket(port);
		System.out.println("TCPServer Waiting for client on port " + port);
		Socket connection = Server.accept();
			


		/** Receive Request */
		if (connection.isConnected()) {
			 receive_PackedRequestData = new BufferedReader(new InputStreamReader(connection.getInputStream()));
			fromclient = receive_PackedRequestData.readLine();
			
			System.out.println("--- Request Received from Client--- ");
			System.out.println( ISOUtil.hexString(fromclient.getBytes()));
		}

		/** Send the response */
		if (connection.isConnected()) {
			//Construct Response Message
			isoMsg=new ISOMsg();
			GenericPackager packager = new GenericPackager("basic.xml");
			isoMsg.setPackager(packager);
			isoMsg.setMTI("0310"); 
			byte[] send_PackedResponseData = msg.pack();
			
			outStream = new BufferedOutputStream(connection.getOutputStream());
			outStream.write(send_PackedResponseData);
			outStream.flush();
			
			System.out.println("-------RESPONSE sent---------");
			System.out.println(ISOUtil.hexString(send_PackedResponseData));
		}
		
		receive_PackedRequestData.close();
		outStream.close();
		connection.close();
Note : I'm running servercode and client code in seperate instance of eclipse on the same machine.