Error in bind() when implementing TCP implementation

I am using the sample TCP sample in order to establish a connection with a TCP server with a certain port number. I checked if the connection is in general is successful or not using telnet open "xx.xx.xx" portnumber which was successful.

In the above sample, the server address was random using 

Fullscreen
1
sin.sin_addr.s_addr = htonl(INADDR_ANY);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 with which the connection was successful,

I replaced it with 

Fullscreen
1
2
3
4
5
6
7
8
9
if (inet_pton(AF_INET, "xxx.xxx.xx.xxx", &sin.sin_addr.s_addr) <= 0) {
perror("Invalid address");
}
sin.sin_family = AF_INET;
sin.sin_port = htons(UDP_PORT);
if (bind(fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
perror("bind");
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 

which is causing error   

Fullscreen
1
2
3
4
TCP sample has started
Waiting for network.. OK
Error: bind(): Network is unreachable
exit
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I am also attaching my project.

SDK: v2.3.0,actinius icarus, nrf9160 dk as flashing device

https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-acb8414431a6410e846db12214a3f070/tcp.zip

Can you tell me what I am doing wrong here?