Code using Java TCP functions