#include <netinet/in.h>
#include <netinet/ip.h>
#include <sys/ioctl.h>
+#include <sys/select.h>
#include <sys/socket.h>
#include <sys/types.h>
return 0;
}
+int MOREP_Receive_timeout (int index, uint8_t *msgtype, uint8_t *buffer, int *len, int ms)
+{
+
+ VERBOSE (morep, TRACE, PRINTF ("MOREP_Receive_timeout\n"));
+
+ if (MOREP_list[index]->used) {
+ return -1;
+ }
+ int fid = MOREP_list[index]->sock;
+
+ fd_set rfds;
+ struct timeval tv = { 0, ms };
+ FD_ZERO (&rfds);
+ FD_SET (fid, &rfds);
+
+ int retval = select (fid + 1, &rfds, NULL, NULL, &tv);
+ if (retval != 1) {
+ return retval;
+ }
+
+ return MOREP_Receive (index, msgtype, buffer, len);
+}
+
/* vim: set ts=4 sw=4 si et: */
int MOREP_Receive (int index, uint8_t *msgtype, uint8_t *buffer, int *len);
+/**
+ @ingroup MOREP
+
+ Received a message over an existing MOREP connection with a timeout.
+
+ @param index MOREP descriptor retuned by MOREP_Connect()
+ @param msgtype a pointer to retrieve the user defined message type
+ identifier, transported transparently
+ @param buffer a pointer to the reception buffer (pre-allocated)
+ @param len a pointer to retrieve the length of the received message
+ @param ms exit after x microseconds if no data is received
+
+ Be carreful that recevied message can be as large as 16 * (ETHERSIZE - 4) - 1 bytes
+
+ @return sequence number of the received message
+
+ @see MOREP_Connect()
+*/
+
+int MOREP_Receive_timeout (int index, uint8_t *msgtype, uint8_t *buffer, int *len, int ms);
+
__END_DECLS
#endif /* __MOREP_H__ */