Whats's causing this issue?

Hi all, need some help with the issue below. Basically if I run the code as is below it works fine, pings an IP and returns the result. If I uncomment the code in the function XML_response the ping code no longer works and I don't see any output on the Serial Monitor.

Appreciate any assistance

Thanks

#include <SPI.h>
#include <Ethernet.h>
#include <ICMPPing.h>
#include <SD.h>
// size of buffer used to capture HTTP requests
#define REQ_BUF_SZ   60

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; // max address for ethernet shield
byte ip[] = {192,168,100,30}; // ip address for ethernet shield
IPAddress pingAddr(192,168,100,100); // ip address to ping
EthernetServer server(80);  // create a server at port 80

SOCKET pingSocket = 0;
unsigned long currentMillis;
unsigned long previousMillis;
unsigned long previousMillis2;

char buffer [256];
ICMPPing ping(pingSocket, (uint16_t)random(0, 255));
int FanSwitchPIN = 7;
int RebootPIN = 8;
int TempSensorPIN = 0;
int buttonState = 0;
int TempSensor = 0;


//File webFile;               // the web page file on the SD card
char HTTP_req[REQ_BUF_SZ] = {0}; // buffered HTTP request stored as null terminated string
char req_index = 0;              // index into HTTP_req buffer
boolean OUTPUT_state[8] = {0}; // stores the states of the outputs

void setup()
{
	// start Ethernet
	Ethernet.begin(mac, ip);
	server.begin();           // start to listen for clients
	Serial.begin(9600);
	pinMode(3, INPUT);        // switch is attached to Arduino pin 3
	pinMode(FanSwitchPIN, OUTPUT);
	pinMode(RebootPIN, OUTPUT);
	RunPing();
	ReadSensor();
	delay(1000);
}
void RunPing()
{
	ICMPEchoReply echoReply = ping(pingAddr, 4);
	if (echoReply.status == SUCCESS)
	{
		sprintf(buffer,
		"Reply[%d] from: %d.%d.%d.%d: bytes=%d time=%ldms TTL=%d",
		echoReply.data.seq,
		echoReply.addr[0],
		echoReply.addr[1],
		echoReply.addr[2],
		echoReply.addr[3],
		REQ_DATASIZE,
		millis() - echoReply.data.time,
		echoReply.ttl);
	}
	else
	{
		sprintf(buffer, "Echo request failed; %d", echoReply.status);
	}
	Serial.println(buffer);
	delay(3000);
}

void ReadSensor()
{
	TempSensor = analogRead(TempSensorPIN);
	//Serial.println(TempSensor);
}

void loop()
{
	currentMillis = millis();
	if(currentMillis - previousMillis > 1000) {
		previousMillis = currentMillis;
		ReadSensor();
	}
	
	if(currentMillis - previousMillis2 > 5000) {
		previousMillis2 = currentMillis;
		RunPing();
	}
	buttonState = digitalRead(3);

	// check if the pushbutton is pressed.
	// if it is, the buttonState is HIGH:
	if (buttonState == HIGH) {
		// turn LED on:
		digitalWrite(RebootPIN, HIGH);
	}
	else {
		// turn LED off:
		digitalWrite(RebootPIN, LOW);
	}

	EthernetClient client = server.available();  // try to get client
	if (client) {  // got client?
		boolean currentLineIsBlank = true;
		while (client.connected()) {
			if (client.available()) {   // client data available to read
				char c = client.read(); // read 1 byte (character) from client
				if (req_index < (REQ_BUF_SZ - 1)) {
					HTTP_req[req_index] = c;          // save HTTP request character
					req_index++;
				}
				
				if (c == '\n' && currentLineIsBlank) {
					client.println("HTTP/1.1 200 OK");
					if (StrContains(HTTP_req, "ajax_inputs")) {
						client.println("Content-Type: text/xml");
						client.println("Access-Control-Allow-Origin: *");
						client.println("Connection: keep-alive");
						client.println();
						SetLEDs();
						// send XML
						XML_response(client);
					}
					else {  // web page request
						client.println("Content-Type: text/html");
						client.println("Connection: keep-alive");
						client.println("Here is the HTML page");
						client.println();
					}
					// reset buffer index and all buffer elements to 0
					req_index = 0;
					StrClear(HTTP_req, REQ_BUF_SZ);
					break;
				}
				if (c == '\n') {
					currentLineIsBlank = true;
				}
				else if (c != '\r') {
					currentLineIsBlank = false;
				}
			} // end if (client.available())
		} // end while (client.connected())
		delay(1);      // give the web browser time to receive the data
		client.stop(); // close the connection
	} // end if (client)
}

void XML_response(EthernetClient cl)
{
	//cl.println("<?xml version = \"1.0\" ?>");
	//cl.println("<IO>");
	//cl.print("<temp>");
	//cl.print(analogRead(TempSensorPIN));
	//cl.print("</temp>");
	//cl.print("<fan>");
	//cl.print(digitalRead(FanSwitchPIN));
	//cl.print("</fan>");	
	//cl.println("</IO>");
}


// checks if received HTTP request is switching on/off LEDs
// also saves the state of the LEDs
void SetLEDs(void)
{
	// server rack fan
	if (StrContains(HTTP_req, "FAN=1")) {
		OUTPUT_state[FanSwitchPIN] = 1;  // save pin state
		digitalWrite(FanSwitchPIN, HIGH);
		Serial.println("fan on");
	}
	else if (StrContains(HTTP_req, "FAN=0")) {
		OUTPUT_state[FanSwitchPIN] = 0;  // save pin state
		digitalWrite(FanSwitchPIN, LOW);
		Serial.println("fan off");
	}
}




// sets every element of str to 0 (clears array)
void StrClear(char *str, char length)
{
	for (int i = 0; i < length; i++) {
		str[i] = 0;
	}
}

// searches for the string sfind in the string str
// returns 1 if string found
// returns 0 if string not found
char StrContains(char *str, char *sfind)
{
	char found = 0;
	char index = 0;
	char len;

	len = strlen(str);
	
	if (strlen(sfind) > len) {
		return 0;
	}
	while (index < len) {
		if (str[index] == sfind[found]) {
			found++;
			if (strlen(sfind) == found) {
				return 1;
			}
		}
		else {
			found = 0;
		}
		index++;
	}

	return 0;
}

If I uncomment the code in the function XML_response

You waste more SRAM. Probably more than you have. All those string literals get copied, unnecessarily, into SRAM at runtime. Stop that by using the F() macro.

client.println(F("HTTP/1.1 200 OK"));

Thanks PaulS will give that a try and let you know.

edit
Thanks very much, issue has been resolved!!