@Override
	public void run() 
	{
		String received=null;// sets up the recieved string

	    
	    // creates a new datagram socket to link to robbie
	      
	      while (constant) //for sending mesages
	      {  
	    	  byte[] object = new byte[1400];
	    	  DatagramPacket packet = new DatagramPacket(object, object.length);
	         
	    		  
		      try {
					socket.receive(packet);
				} catch (IOException e1) {
					// TODO Auto-generated catch block
					System.err.println("Didn't recieve a valid packet.");
					e1.printStackTrace();
				}// recieves the packet 2010
		    	  received=new String(packet.getData());     // sets up the recieved string with the packet data
		    	  if (received.indexOf("X")!=-1) // if the packet is an order taken 
		    	  {
		    		            //System.out.println("message recieved by server");
		    		            String output = ("Message recieved by server \n");
		    	         	    test.append(output);

		    	    		     //packet = new DatagramPacket(sendBytes, sendBytes.length, ipaddress, 8444);  // sets up a new packet based on the bytes
		    	    		     try {
									socket1.send(packet);// sends the packet to robbie   
								} catch (IOException e) {
									// TODO Auto-generated catch block
									System.err.println("Couldn't send the packet.");
									e.printStackTrace();
								}    	
			    		            String output2 = ("Message sent to Robbie \n");
			    	         	    test.append(output2);

		    	    		     
		    	  }  
		    	  
		    	  else //if the packet is a request for an order
		    	  {
		    		  System.out.println("message not recieved by the server, please try again");
		    	  }
	       
	    	  } 
	    	  
	      	while(constant) // for recieving packets
	    		{
	      		 byte[] object = new byte[1400];
		    	  DatagramPacket packet = new DatagramPacket(object, object.length);
		         
		    		  
			      try 
			      {
						socket1.receive(packet);// try to recieve a packet from robbie
			      } 
			      catch (IOException e1) 
					{
						System.err.println("Didn't recieve a valid packet.");
						e1.printStackTrace();
					}
			      
					if (received.indexOf("X")!=-1) // if the packet is an order taken 
			    	  	{
			    			//System.out.println("message recieved by server");
			    		    String output = ("Robbie has encountered an object and needs a new path");
			    	        test1.append(output);
			    	    		     
			    	  	}  
			    	else //all packets from robbie begin with help, therefor if the first part of the packet isnt help thers an error
			    	  	{
		
			    		  	System.out.println("message not recieved by the server, please try again");

			    	  	}
	    		}
	    	    socket.close();//closes the socket
	    	    socket1.close();//closes the socket
	      }