Jump to content

Server/Client discussion


 Share

Recommended Posts

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...