Skip to content
This repository was archived by the owner on Jun 8, 2021. It is now read-only.

Commit e96cb7f

Browse files
author
Antti Kauppila
authored
Merge pull request #40 from michalpasztamobica/remove_deprecated_apis
Replace string-based APIs with SocketAddress-based ones
2 parents 2b35425 + b9bd18c commit e96cb7f

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

main.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,27 +53,34 @@ int main(void)
5353

5454
printf("Connecting to network\n");
5555
result = net->connect();
56-
if (result != 0) {
56+
if (result != NSAPI_ERROR_OK) {
5757
printf("Error! net->connect() returned: %d\n", result);
5858
return result;
5959
}
6060

6161
TLSSocket *socket = new TLSSocket;
6262
result = socket->set_root_ca_cert(cert);
63-
if (result != 0) {
63+
if (result != NSAPI_ERROR_OK) {
6464
printf("Error: socket->set_root_ca_cert() returned %d\n", result);
6565
return result;
6666
}
6767

6868
result = socket->open(net);
69-
if (result != 0) {
69+
if (result != NSAPI_ERROR_OK) {
7070
printf("Error! socket->open() returned: %d\n", result);
7171
return result;
7272
}
7373

7474
printf("Connecting to ifconfig.io\n");
75-
result = socket->connect("ifconfig.io", 443);
76-
if (result != 0) {
75+
SocketAddress addr;
76+
result = net->gethostbyname("ifconfig.io", &addr);
77+
if (result != NSAPI_ERROR_OK) {
78+
printf("Error! DNS resolution for ifconfig.io failed with %d\n", result);
79+
}
80+
addr.set_port(443);
81+
82+
result = socket->connect(addr);
83+
if (result != NSAPI_ERROR_OK) {
7784
printf("Error! socket->connect() returned: %d\n", result);
7885
goto DISCONNECT;
7986
}

mbed-os.lib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
https://github.com/ARMmbed/mbed-os/#b81aeff1a3e171c6421984faa2cc18d0e35746c0
1+
https://github.com/ARMmbed/mbed-os/#64853b354fa188bfe8dbd51e78771213c7ed37f7

0 commit comments

Comments
 (0)