Arduino 101 can't connect to ESP8266 from source code, but Arduino uno can connect to it using same program.
Is this program mistake?
If it works in Arduino, then the program is fine (as well as hardware, and every involved software such as libraries). Intel products are not always compatible with hardware/software working fine in the "Arduino world".
I do not have any Arduino 101 at hand, I've made some minimal experiments with Intel Galileo-ESP8266, like that reported at Wi-Fi module ESP8266 in Galileo.
I'd suggest asking in an Arduino 101 specific forum, since this one is intended for Intel Galileo. The (Arduino site) suggested forum for Arduino 101 is https://forum.arduino.cc/index.php?board=103.0
This message was posted on behalf of Intel Corporation
Even though the Arduino 101 board is based on the Curie module, the support is provided directly by Arduino.cc. As FGT already mentioned, I recommend you to post your question in the Arduino 101 forum in the following site: https://forum.arduino.cc/index.php?board=103.0. You will receive better assistance there.