ESP8266 TCP keep Alive

I am trying to implement TCP keepalive function on a ESP8266 in the Arduino environment. I have located some information on keepalive on Expressif site
http://bbs.espressif.com/viewtopic.php?f=7&t=2771&p=9814&hilit=Keepalive#p9814

The keepalive basically sends a TCP heartbeat message every X seconds to the attached client(s) and if the client does not respond in X seconds for X times the socket is disconnected.

I have added the following code to my sketch

int keep_alive = 30; //keep alive checking per 30 seconds
espconn_set_opt(my_espconn, ESPCONN_KEEPALIVE);
espconn_set_keepalive(my_espconn, ESPCONN_KEEPIDLE, &keep_alive);
keep_alive = 5; //repeat interval = 5 seconds
espconn_set_keepalive(my_espconn, ESPCONN_KEEPINTVL, &keep_alive);
keep_alive = 2; //repeat 2 times
espconn_set_keepalive(my_espconn, ESPCONN_KEEPCNT, &keep_alive);

I am getting the following compile error
'my_espconn' was not declared in this scope

I have never work directly with the ESP8266 SDK and I am not sure what my_espconn should be define as and what value it should be.

Any help would be appreciated