Last post Sep 23, 2013 03:31 AM by Ericzh
Sep 18, 2013 04:33 PM|solo812|LINK
I am hoping to reach out to the community today for some "best practices" guideance.
I currently have 7 WCF hosts that have been written that are supposed so host the WCF service on any available port within a specified range. We have a function that finds an available port within the OS and returns it to the host having already been reserved
using the "bind" method.
My question with the following code is:
1) With all services coming through this same "FindAvailablePort" process, do we need a mutex as coded below?
2) Is there any chance of a race condition?
Dim portMutex As Mutex = ObtainNamedMutex("MyMutexName" & Guid.NewGuid().Tostring())
'returns a new mutex with a unique name for all seven services.
Dim endPoint As New IPEndPoint(IPAddress.Any, 0)
Using socket As New Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)
Dim local As IPEndPoint = DirectCast(socket.LocalEndPoint, IPEndPoint)
Sep 23, 2013 03:31 AM|Ericzh|LINK
You could refer to the following links for more information: