This repository was archived by the owner on Jun 8, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -53,27 +53,34 @@ int main(void)
53
53
54
54
printf (" Connecting to network\n " );
55
55
result = net->connect ();
56
- if (result != 0 ) {
56
+ if (result != NSAPI_ERROR_OK ) {
57
57
printf (" Error! net->connect() returned: %d\n " , result);
58
58
return result;
59
59
}
60
60
61
61
TLSSocket *socket = new TLSSocket;
62
62
result = socket->set_root_ca_cert (cert);
63
- if (result != 0 ) {
63
+ if (result != NSAPI_ERROR_OK ) {
64
64
printf (" Error: socket->set_root_ca_cert() returned %d\n " , result);
65
65
return result;
66
66
}
67
67
68
68
result = socket->open (net);
69
- if (result != 0 ) {
69
+ if (result != NSAPI_ERROR_OK ) {
70
70
printf (" Error! socket->open() returned: %d\n " , result);
71
71
return result;
72
72
}
73
73
74
74
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) {
77
84
printf (" Error! socket->connect() returned: %d\n " , result);
78
85
goto DISCONNECT;
79
86
}
You can’t perform that action at this time.
0 commit comments