Sign in to follow this  
Followers 0
ending

Server/Client discussion

6 posts in this topic

I'm working on a program that links computers together to share variables from another scripting engine (for a game). I'm going to have a server version of this that I will run and my friends can use the clients to connect to my server, and share the variables. The variables from the other scripting engine are stored in the registry, and I'm keeping track of them by having two arrays. One for variable name and one for it's value.

The following is my thinking on the method, this is where I need support/clarification/criticism:

So basically, when I have the client version send a variable to the server, it will be a string with a delimiter seperating the two, and then I'll forward it onto the other clients. Once the clients recieve the data from the server, it parses out the variable and value then writes it to the registry.

Also, on the client version I want to make it so you log into the the server with a username and pass. So on the listening server I'll have to create my own 'string packet' like "conn:user:password" and if the user and password match a list that the server has, it allows the connection. Also, I would like to have the clients able to see who is logged on the server. Basically what I'm trying to figure out is if the best approch to this is to define parsing functions for certain string packets. For example:

[packet identifier]:[data]:[more data]

So a list I'll need is:

"conn:user:pass" - Client -> Server for connecting

"send:var:value" - Client -> || <- Server for sharing a variable (forwarding it to the other users)

"add:user" - Server -> Client for add a user to the list (the user connected)

"del:user" - Server -> Client for removing a user from the list (the user disconnected)

Any help is appriciated. I've never written a client/server app and I'm also learning AutoIt as I go, but I have a pretty solid client version so far.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Also, on the client version I want to make it so you log into the the server with a username and pass. So on the listening server I'll have to create my own 'string packet' like "conn:user:password" and if the user and password match a list that the server has, it allows the connection. Also, I would like to have the clients able to see who is logged on the server.

Quite some time ago, I made a chat program that worked exactly like this. Users were stored in a simple INI file and passwords were sent unencrypted, so it wasn't the most secure system ever, but that should work for your purposes.

For sending information I used character ALT+250 ( · ), followed by a capital four-letter "tag", then the relevant data, the same tag again, and another ALT+250 at the end. I just chose that character because you're extremely unlikely to want to use it during normal conversation, so it doesn't really matter that you can't. A message packet might look like this:

·TEXTHi there!TEXT·

I did it like this because TCP may sometimes split a large packet into multiple pieces, or combine multiple smaller packets into one (if they are sent in rapid succession). Since TCP does guarantee that your data will arrive in the same order it left in, the above structure allows you to just put all incoming data into a receiving buffer, and parse it as soon as you can find a complete "chunk" to interpret.

For doing the variable/value thing, if you wanted to go with a system similar to the one I described, I suppose you could put another separator within the data, like ·MARKsomedata|moredataMARK· (using a pipe as an example). Just make sure you check for it in the actual data to avoid errors, and that it's not something you'll ever be using in the data on purpose.

Edited by Sokko

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thats something that I didn't think about, the packet splitting. Thanks for the warning! I'll have to include the end-tag at the end of the string. Some variables are quite long indeed.

I'm glad to see I have the right method of thinking.

Thanks for the input.

Edit: Also, for some simple security is use the string encryption thing and hardcode a password into the client and server modules. Or just hash the string.

Edited by ending

Share this post


Link to post
Share on other sites

Check my signature for TCP server stuffs. All very possible using AdminDB and StringEncrypt/Hex.

Share this post


Link to post
Share on other sites

I don't think I'll bother encrypting it because its not really sensitive data being transmitted. Plus, its just one more thing to do that takes up power.

Share this post


Link to post
Share on other sites

Just wanted to give another thanks to those who helped me. I succesfully created my server and client that use a username and password from an INI file. Still need to do some testing but as far as I know its working! :D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0