4 Replies - 3494 Views - Last Post: 09 June 2010 - 02:23 AM Rate Topic: -----

#1 Lightbeam  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 23-February 10

License server via TCP connections

Posted 23 February 2010 - 02:42 PM

Hello,

I need to add some floating license to an application. What i want to do is making a license server which will be a windows service.
When the application (which is shared on a server) starts it will connect to the License Server. The License Server will check the number of client running and tell the new started client that it can be started or not.

In this way it is easy to change the license system of an application later.

Is this a good practice to do? If some guys have better ideas, let me know!

The problem i have with the TCP connections is that i'm not able to check the state of the connection between the server and the new client when a client is unexpected shutdown.
A client needs to be removed from the running list in the license server when i a client shutdown. Sometimes is it not possible to close the TCP connection properly when the client raises an error.

I was also thinking about broadcasting a packet to all clients in the running list of the license server. The clients which response to the broadcast are active. The other clients are inactive and can be removed from the running list.

I can't find out how to implement these things..
I currently have a simple TCP server with client. The client can perfectly communicate to the server but i'm not able to get the server updating the list of the active clients.

I hope you guys can give me some good idea's or some ways to do it!

Thx,
Lightbeam

Is This A Good Question/Topic? 0
  • +

Replies To: License server via TCP connections

#2 Weebo  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 5
  • Joined: 23-February 10

Re: License server via TCP connections

Posted 23 February 2010 - 08:31 PM

I do have a suggestion for you, and an answer if need be. However, I'd recommend using WCF either in IIS or hosted by a Windows Service. Or if you are familiar with ASP.NET, perhaps a web service.

TCP streams can get quite ugly and I've found that using either WCF or ASP.NET Web Services are much cleaner and easier. TCP/UDP streams are better suited if you are sending over binary data, such as an audio/video stream. In your case, it sounds like you want to send commands. For you to send commands via the stream, you'd have to convert string based commands with parameters to byte arrays. Once the server received the packets, the data would then need to be converted back into a string. After that, the parsing isn't clean: split, compare; split, compare; etc. Quite frankly, sending the parameters to a method in an WCF/ASP.NET Web Service is much easier and cleaner. It allows for more expansion and will save time.

If you go and change it to use ASP.NET or WCF, here is the answer to your main question:


Quote

A client needs to be removed from the running list in the license server when i a client shutdown. Sometimes is it not possible to close the TCP connection properly when the client raises an error.

The best way to do this without using too much RAM, would be to write the IP or other data from a newly connected client to a temporary file. Xml serialization (Google/Bing "XmlSerializer examples") would be the easiest way to accomplish this. Create an object (class) that represents a client. Make sure to include any properties that you'll need from the client (e.g.: IP address, time stamp of connection, ID number, etc). Then serialize the array/list of client objects to a file. When needed, de-serialize the file back into a client array/list. It is much easier than just reading and writing a plain text file.

When a client is being killed (exited), have it call the web service's "remove" method with an ID or IP. That will then de-serialize the client array/list and remove the client from the array/list.


That said, if you still want to use an old fashioned TCP server (in .NET, no less!), I'm sure either I or someone else can help you with that.
Was This Post Helpful? 1
  • +
  • -

#3 Lightbeam  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 23-February 10

Re: License server via TCP connections

Posted 09 June 2010 - 01:49 AM

First of all sorry for the late response because the project was set to 'HOLD'.
Anyway thanks for replying that fast!


I understand that WCF clients will be cleaner. But we still have some old FoxPro programs running wich we will also license with the server...
I think it's easier from FoxPro to connect with a TCP server then a webservice.

Serializing/Deserializing the list of clients isn't any problem.

The problem is that we currently can't detect from the license server if the client is still online or offline when the client has a connection lost.
When the client has a connection lost he can't send messages anymore to the server to log off..

That is the problem we now have with the tcp server.

I hope someone can help us out
Was This Post Helpful? 0
  • +
  • -

#4 Rico Diesel  Icon User is offline

  • D.I.C Head

Reputation: 62
  • View blog
  • Posts: 122
  • Joined: 06-May 10

Re: License server via TCP connections

Posted 09 June 2010 - 02:17 AM

Maybe you could use the "Keep Alive" signal of the TCP protocol, or simply built your own "Keep Alive" signal into the messages you are using.

Never done this myself, but this is what I found with a quick google search : Wikipedia and devnewsgroup and last but not least an Howto

Maybe this completely wrong and the last thing you are looking for, but this was the first thing that I could think off.

Hope this helps,

Rico
Was This Post Helpful? 1
  • +
  • -

#5 Lightbeam  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 23-February 10

Re: License server via TCP connections

Posted 09 June 2010 - 02:23 AM

I looked at the examples and it looks really usefull!

I going to try it later and let you know :)

Thx!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1