mbed socket API
Dependents: EthernetInterface EthernetInterface_RSF EthernetInterface EthernetInterface ... more
Deprecated
This is an mbed 2 sockets library. For mbed 5, network sockets have been revised to better support additional network stacks and thread safety here.
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;
}
mbed official


