static public OTAMessageIntf recv(DataInputStream input) throws Exception{	
		   
		   OTAMessageIntf msg = null;
		   int ret = 0;
		   try {
			   byte [] header_temp = new byte[header_size];
			   ret = input.read(header_temp);
			   if(ret == -1)
				   throw new Exception ("Socket read failed - header");

			  OTAMessageHeader header =  new OTAMessageHeader(header_temp);
			  switch((byte)header.getMessage_type())
			  {
				case MOBILE_ORIGINATED_EVENT:
					msg = new OTAMessageMOE(header);
					break;

				case MOBILE_ORIGINATED_ACK:
					msg = new OTAMessageMOA(header);
					break;

				case MOBILE_TERMINATED_EVENT:
					msg = new OTAMessageMTE(header);
					break;
			   
				case MOBILE_TERMINATED_ACK:
					msg = new OTAMessageMTA(header);
					break;
					
				 default:
					 throw new Exception("UNRECOGNIZED MESSAGE");
			  }
			  
			  
              
			  msg.readObjs(input);
			  
			  int in_crc = input.read();
			   if(in_crc == -1)
				   throw new Exception ("Socket read failed - crc");
			   
				//int my_crc = (int) msg.updateCRC();
			   byte recvCRC = (byte) (in_crc & 0x000000FF); 
			   byte myCRC = msg.updateCRC();
		   	   if (recvCRC != myCRC) 
			   		throw new Exception (" Mismatched crc. Recvd CRC = " + recvCRC + ", My CRC = " + myCRC);
		   } 	
		   catch (IOException e)
		   {
			   throw e;
		   }
		   catch (Exception e)
		   {
			   throw e;
		   }
		   return msg;
		
		}