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

Replace string-based APIs with SocketAddress-based ones #40

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,34 @@ int main(void)

printf("Connecting to network\n");
result = net->connect();
if (result != 0) {
if (result != NSAPI_ERROR_OK) {
printf("Error! net->connect() returned: %d\n", result);
return result;
}

TLSSocket *socket = new TLSSocket;
result = socket->set_root_ca_cert(cert);
if (result != 0) {
if (result != NSAPI_ERROR_OK) {
printf("Error: socket->set_root_ca_cert() returned %d\n", result);
return result;
}

result = socket->open(net);
if (result != 0) {
if (result != NSAPI_ERROR_OK) {
printf("Error! socket->open() returned: %d\n", result);
return result;
}

printf("Connecting to ifconfig.io\n");
result = socket->connect("ifconfig.io", 443);
if (result != 0) {
SocketAddress addr;
result = net->gethostbyname("ifconfig.io", &addr);
if (result != NSAPI_ERROR_OK) {
printf("Error! DNS resolution for ifconfig.io failed with %d\n", result);
}
addr.set_port(443);

result = socket->connect(addr);
if (result != NSAPI_ERROR_OK) {
printf("Error! socket->connect() returned: %d\n", result);
goto DISCONNECT;
}
Expand Down
2 changes: 1 addition & 1 deletion mbed-os.lib
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://github.com/ARMmbed/mbed-os/#b81aeff1a3e171c6421984faa2cc18d0e35746c0
https://github.com/ARMmbed/mbed-os/#64853b354fa188bfe8dbd51e78771213c7ed37f7