#include <sys/socket.h>
#include <netdb.h>
#include "aros_compat.h"
+#include <errno.h>
+#include <bsdsocket/socketbasetags.h>
#undef poll
struct Library * SocketBase = NULL;
+extern int errno;
+int h_errno = 0;
+
+
void aros_init_socket(void)
{
if (!(SocketBase = OpenLibrary("bsdsocket.library", 4))) {
printf("NoTCP/IP Stack available");
exit(10);
}
+ if (SocketBaseTags(SBTM_SETVAL(SBTC_ERRNOPTR(sizeof(errno))),
+ (IPTR)&errno,
+ SBTM_SETVAL(SBTC_HERRNOLONGPTR),
+ (IPTR)&h_errno, TAG_DONE)) {
+ printf("Failed to set ERRNO");
+ exit(10);
+ }
}
int aros_poll(struct pollfd *fds, unsigned int nfds, int timo)
{
struct timeval timeout, *toptr;
fd_set ifds, ofds, efds, *ip, *op;
- unsigned int i;
+ unsigned int i, maxfd = 0;
int rc;
// Set up the file-descriptor sets in ifds, ofds and efds.
FD_SET(fds[i].fd, op);
}
FD_SET(fds[i].fd, &efds);
+ if (fds[i].fd > maxfd) {
+ maxfd = fds[i].fd;
+ }
}
// Set up the timeval structure for the timeout parameter
timeout.tv_usec = (timo - timeout.tv_sec * 1000) * 1000;
}
- rc = WaitSelect(0, ip, op, &efds, toptr, NULL);
+ rc = WaitSelect(maxfd + 1, ip, op, &efds, toptr, NULL);
if(rc <= 0)
return rc;