Thanks for the bug report.  I've sent it to the relevant team and I am
waiting for a reply.

John

This posting is provided "AS IS" with no warranties, and confers no
rights.

-----Original Message-----
From: Sanshao Jiang [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, July 03, 2002 12:26 AM
To: [EMAIL PROTECTED]
Subject: What awful codes in Socket.Select


Lookat this, they've made a big mistake.

if socketList[currentSocket] is removed, the new
socketList[currentSocket] is never checked before currentSocket++;

the code below should be

for (currentSocket = 0; currentSocket < socketList.Count; /* WRONG
currentSocket++*/)
{
...
    if (currentFileDescriptor==fileDescriptorSet.Count) {
        //
        // descriptor not found: remove the current socket and start
again
        //
        socketList.RemoveAt(currentSocket);
    }
   /* ADD HERE */
   else currentSocket++;
}

I found this when I use the offical .NET framework with SELECT. but
weird things happen. So I check sscli in FreeBSD, problems remain. From
sscli's source...

To my disappointment, the second Beta Refresh hasn't fixed this error.
How could I believe in .NET and construct my project on it?


source from sscli, in fx\src\net\system\net\sockets\socket.cs
//
// Transform the list socketList such that the only sockets left are
those // with a file descriptor contained in the array
"fileDescriptorArray" // ... for (currentSocket = 0; currentSocket <
socketList.Count; currentSocket++) {
    //
    // parameter validation: only Socket should be here
    //
    if (!(socketList[currentSocket] is Socket)) {
        throw new ArgumentException("socketList");
    }

    socket = (Socket)socketList[currentSocket];

    //
    // Look for the file descriptor in the array
    //
    for (currentFileDescriptor = 0; currentFileDescriptor <
fileDescriptorSet.Count; currentFileDescriptor++) {
        if (fileDescriptorSet.Array[currentFileDescriptor]
==socket.m_Handle) {
            break;
        }
    }

    if (currentFileDescriptor==fileDescriptorSet.Count) {
        //
        // descriptor not found: remove the current socket and start
again
        //
        socketList.RemoveAt(currentSocket);
    }
}

Reply via email to