Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: lwip-eth lwip-sys lwip
Fork of LWIPInterface by
Revision 16:1efb0d91c223, committed 2016-04-06
- Comitter:
- geky
- Date:
- Wed Apr 06 10:45:34 2016 +0000
- Parent:
- 15:0d8d1dafe064
- Commit message:
- Added support for bind call
Changed in this revision
| LWIPInterface.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/LWIPInterface.cpp Wed Apr 06 00:20:35 2016 +0000
+++ b/LWIPInterface.cpp Wed Apr 06 10:45:34 2016 +0000
@@ -154,7 +154,19 @@
int LWIPInterface::socket_bind(void *handle, int port)
{
- return NSAPI_ERROR_UNSUPPORTED;
+ int fd = (int)handle-1;
+ struct sockaddr_in sa;
+ memset(&sa, 0, sizeof sa);
+
+ sa.sin_family = AF_INET;
+ sa.sin_port = htons(port);
+ sa.sin_addr.s_addr = INADDR_ANY;
+
+ if (lwip_bind(fd, (const struct sockaddr *)&sa, sizeof sa) < 0) {
+ return NSAPI_ERROR_DEVICE_ERROR;
+ }
+
+ return 0;
}
int LWIPInterface::socket_listen(void *handle, int backlog)
