Solve buffer overflow in tcp and ssl clients