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.
Fork of Socket by
Diff: Socket.cpp
- Revision:
- 10:d24738f4ef99
- Parent:
- 6:cd2e5559786d
- Child:
- 11:3d83c348fb8b
--- a/Socket.cpp Fri Jul 27 15:56:20 2012 +0000
+++ b/Socket.cpp Tue Jul 31 11:50:55 2012 +0000
@@ -20,10 +20,15 @@
using std::memset;
-Socket::Socket() : _sock_fd(-1) {
+Socket::Socket() : _sock_fd(-1), _blocking(true), _timeout(3000) {
}
+void Socket::set_blocking(bool blocking, unsigned int timeout) {
+ _blocking = blocking;
+ _timeout = timeout;
+}
+
int Socket::init_socket(int type) {
if (_sock_fd != -1)
return -1;
@@ -37,9 +42,6 @@
}
int Socket::select(struct timeval *timeout, bool read, bool write) {
- if ((timeout->tv_sec == 0) && (timeout->tv_usec == 0))
- return 0;
-
fd_set fdSet;
FD_ZERO(&fdSet);
FD_SET(_sock_fd, &fdSet);
@@ -69,7 +71,7 @@
return 0;
}
-TimeInterval::TimeInterval(int ms) {
+TimeInterval::TimeInterval(unsigned int ms) {
_time.tv_sec = ms / 1000;
_time.tv_usec = (ms - (_time.tv_sec * 1000)) * 1000;
}
