avance70 avance70 - 5 months ago 38
C# Question

How To Limit a WCF Service Application, So That Only Unique Clients Can Access

i have a wcf service in c# (like the calculatorservice from msdn examples), and i was wondering is it possilble to limit it to serve only 1 client per IP?

i want the possibility of a few IPs to be connected at once (at least 5-6 active sessions), and that works for now, but i don't want more than 1 connection per unique IP (or unique computer)


i made some progress. when the client invokes the service for the first time, in the constructor i save his ip address and his current operation context.

then, if someone from the same ip connects, i abort the previous channel that that ip address used (newest connection has the priority):


i tested it, and it appears to free up the session so others can use it, but i am not sure -- is this the best solution?