fix UDP code to work with a higher socket fd

This commit is contained in:
Douglas Clowes
2012-12-13 13:50:32 +11:00
parent da1213c059
commit 6ca55df3d6

View File

@ -188,7 +188,7 @@ mkChannel *NETAccept(mkChannel * self, long timeout)
return NULL; /* eof */
}
iRet =
uselect((self->sockid + 1), (fd_set *) & lMask, NULL, NULL, &tmo);
uselect((self->sockid + 1), &lMask, NULL, NULL, &tmo);
if (iRet <= 0) {
/* failure, or no request */
return NULL;
@ -848,7 +848,7 @@ mkChannel *UDPOpen(int iPort)
i = 1;
setsockopt(pRes->sockid, SOL_SOCKET, SO_REUSEADDR, &i, sizeof(int));
assert(pRes->sockid < (sizeof(long) * 8));
assert(pRes->sockid < FD_SETSIZE);
/* if this fails the masks for select will be to
short.
*/
@ -924,7 +924,7 @@ mkChannel *UDPConnect(char *name, int port)
/*--------------------------------------------------------------------------*/
long UDPRead(mkChannel * self, char *buffer, long lLen, int timeout)
{
long lMask = 0L;
fd_set lMask;
struct timeval tmo = { 0, 1 };
long iRet;
socklen_t iLang;
@ -938,9 +938,10 @@ long UDPRead(mkChannel * self, char *buffer, long lLen, int timeout)
/* setup for select first */
tmo.tv_usec = (timeout % 1000) * 1000;
tmo.tv_sec = timeout / 1000;
lMask = (1 << self->sockid);
FD_ZERO(&lMask);
FD_SET(self->sockid, &lMask);
iRet =
uselect((self->sockid + 1), (fd_set *) & lMask, NULL, NULL, &tmo);
uselect((self->sockid + 1), &lMask, NULL, NULL, &tmo);
if (iRet <= 0) {
/* failure, or no data */
return 0;