We have an application that has a 200 count loop that does the following:
' Each time thru the loop we pass the next IP Address is a range (aka
192.168.4.50 thru 192.168.4.254)
Try
If mUIO_Threads(i) Is Nothing Then
mUIO_Threads(i) = New System.Threading.Thread(AddressOf
mUIO_DAQ(i).InitDAQ)
mUIO_Threads(i).Name = mUIO_DAQ(i).UIO_IPAddr
mUIO_Threads(i).IsBackground = False
Else
If Not mUIO_Threads(i) Is Nothing Then
mUIO_Threads(i).Abort()
While mUIO_Threads(i).ThreadState=Threading.ThreadState. Running
End While
mUIO_Threads(i) = Nothing
End If
mUIO_Threads(i) = New System.Threading.Thread(AddressOf
mUIO_DAQ(i).InitDAQ)
mUIO_Threads(i).Name = mUIO_DAQ(i).UIO_IPAddr
mUIO_Threads(i).IsBackground = False
End If
mUIO_Threads(i).Start()
stime = Environment.TickCount
While (Environment.TickCount < stime + 100) And (Not mUIO_DAQ(i).UIO_Opened)
System.Windows.Forms.Application.DoEvents()
End While
Catch ex As Threading.ThreadStateException
Debug.WriteLine("Poll: Threading Error <" & ex.ToString & ">")
Catch ex As Exception
Debug.WriteLine("Poll: Exception Error <" & ex.ToString & ">")
End Try
The call to "InitDAQ" creates a TCPIP socket and calls
System.Net.Sockets.Socket.Connect as follows:
Me.m_Socket = New
System.Net.Sockets.Socket(Net.Sockets.AddressFamil y.InterNetwork,
SocketType.Stream, Net.Sockets.ProtocolType.IP)
ipAddressEndPoint = New
System.Net.IPEndPoint(IpAddressArg.Parse(pchIpAddr essArg), nPort)
OpenSockets = SIOMM_OK
Me.m_Socket.Connect(ipAddressEndPoint)
Some of the IP Addresses passed are not online and therefore will fail to
connect. Our test has ip 192.168.4.50 valid and also 192.168.4.253 and
192.168.4.254 valid. All others in the range were offline. We get a
connection working with 192.168.4.50 and eventually after 5 minutes get the
other two also. If we cut the range down to 192.168.4.250 to 192.168.4.254
we connect to 253 and 254 immediately on the first time throught the loop.
If we adjust the range to 192.168.4.240 to 192.168.4.254, we don't connect
the first time through the loop but we do get it the second time through. It
is almost as if we can only get data from the first 10 attempted sockets and
have to wait for them to timeout before we can get data from the next ten.
We have tried setting the socket to Non-Blocking but that didn't seem to
help. We do see spurts of 10 threads exiting at one time. Any ideas