Command ESP 07 ESP8266 over Wireless
The default firmware for the ESP does not save the TCP  server settings by default. You would need either a microcontroller that will set up the server, or replace the firmware with something like Node.js that can set up the server by itself.

As for toggling the gpio, there are many tutorials online for that. That is too broad a question here.