-
Notifications
You must be signed in to change notification settings - Fork 26
Add TLSSocket example #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@AnotherButler Please review & merge. Will be linked into the ongoing TLSSocket documentation PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
@kjbracey-arm FYI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of nit-picks, cos it's an example. Bet most are common with the other socket example though.
TLSSocket/main.cpp
Outdated
// Bring down the ethernet interface | ||
net->disconnect(); | ||
printf("Done\n"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing newline
TLSSocket/main.cpp
Outdated
size = strlen(query); | ||
|
||
// Loop until whole request sent | ||
while(size) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This loop should not be necessary. A blocking socket or file handle is supposed to send everything. (In Unix a signal could interrupt, but not mbed OS).
See ARMmbed/mbed-os#5466 - loop would have been necessary in older OS versions.
Following the logic from that PR, if TLSSocket
needs the loop, it should be fixed to match TCPSocket
.
Missing space, anyway
return result; | ||
} | ||
|
||
TLSSocket *socket = new TLSSocket; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you've configured a big main stack, no particular reason to new
this? Or the buffer?
NetworkInterface *net = NetworkInterface::get_default_instance(); | ||
|
||
if (!net) { | ||
printf("Error! No network inteface found.\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
interface
This is nearly a verbatim copy of Socket examples, but now uses TLSSocket.