Your problem is with the C code. Instead of
char * as = "ki"
use
char as[] = "ki"
or you can do pbuf alloc, maybe that can generate some memory for you.
es->p = pbuf_alloc(PBUF_TRANSPORT, strlen((char*)"ki") , PBUF_POOL);
pbuf_take(es->p, (char*)"ki", strlen("ki"));
Also, you should also check for the return condition, if tcp_write gives you anything else than ERR_OK then you should try again and try harder. I am using tcp write in POLL mechanism, but that is giving low throughput, I am getting comparatively better throughput when I use it in main while loop.