This repository was archived by the owner on Jun 8, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff line change 1- https://github.com/ARMmbed/mbed-os/#b81aeff1a3e171c6421984faa2cc18d0e35746c0
1+ https://github.com/ARMmbed/mbed-os/#64853b354fa188bfe8dbd51e78771213c7ed37f7
You can’t perform that action at this time.
0 commit comments