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 

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

I replaced it with 

		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");
		}
 

which is causing error   

TCP sample has started
Waiting for network.. OK
Error: bind(): Network is unreachable
exit

I am also attaching my project.

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

Can you tell me what I am doing wrong here?

Parents Reply Children
Related