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);
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");
}
which is causing error
Fullscreen
1
2
3
4
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?