Trying to break Connect.dll (Fiona's Worklog)

Craaash... RSS Feed

Bam

So I've been playing with Sandman's new net.dll ALL day.

Now at first there were a slew of errors and problems, most of them have been fixed.
At one point I decided to utilise the is_external parameter on NET_open. This basically tells the DLL not to send any of it's in-built commands, this includes ping/pong, the inital connection messages etc.
(Also to save you some time if anyone decides to do this, you also need to send a message telling a client when you have disconnected it, using the net_close function simlpy isn't enough.)

Now all the problems are pretty much fixed, but I've spent so long doing this custom command and ping/pong system that I don't wanna scrap it, I'm a sucker for punishment anyway.

I started by making a logging system that pretty much throws everything it does into a text file. Also had a couple of functions for it. The trick with this crap is knowing exactly what does what and when. So I log times too.

So I've got a server program that waits for connections from clients, when a client connects it sends "HELLOCLIENT" which will then send back "HELLOSERVER". If the client doesn't send that message it will be disconnected.

The server will periodically send a ping message. If it does not get a pong reply back within a certain amount of time, the server assumes that the user has disconnected and boots them.

Image thumbnail - click to enlarge
(Click thumbnail to enlarge)


That's the client spitting out a few messages.
The incoming server message is 01:0001:4245.

This is split into 3 bits, the second bit (0001) is a command code, I decided that the best way to send messages was by prefixing them with a code and defining them in Fenix like:

Code:
#define CODE_SERVER_PING "0001"
#define CODE_CLIENT_PONG "0002"
#define CODE_CLIENT_DISCONNECT "0666"


So when you recieve a message, it gets those 4 characters and looks in a big switch to find out what's being said.

The third part is the message itself. If you sent "01:0666:Yo ass is owned." to the client, it would swiftly close with the message "Yo ass is owned."

The first part was Sandman's ingenious idea. You see if you've lost a connection the DLL will keep recieveing the last message it got over and over again, it was spamming my logs to death.

So instead each message has an ID number, ranging from 01 to 99, each message sent increments by one, when you get to 99 it goes back to 01.
This let's me easily check if you've recieved the same message (So you can ping the client to find out if they're really dead) and also it's totally simple to check for any messages that might have been lost in transit.

Right, that's what I've been doing today. Doesn't sound like much but it's a crap load of work. *Yawn*

[edit]

The server is now crashing on every 25th message it recieves. What fun.
(Posted on June, 10th 2006, 03:27)

Comments


Rincewind said:
Hm thanks for investigating, does this mean the dll is not so simple after all?
(Posted on June, 10th 2006, 14:25)


Fiona said:
The DLL is very simple. But if you read my post porperly, you'll see I turned off a lot of the built-in features and went my own route.
To be honest, having full control over all that stuff is much better anyway.
(Posted on June, 10th 2006, 14:46)


Rincewind said:
I read your post very porperly.
(Posted on June, 10th 2006, 15:27)


Fiona said:
If you had then you would realise that pretty much every problem was because I was doing things of my own accord.
(Posted on June, 10th 2006, 16:44)


PEader said:
I don't think so.
(Posted on June, 10th 2006, 16:57)


Sandman said:
Wait, are you using a string in a switch()? This is bad. Real bad, because Fenix errors when you do that too much, well 0.84a does. I recommend using a lot of IF()s for strings.
This is probably why it crashes on the 25th message. Case solved.
(Posted on July, 13th 2006, 04:46)

Post New Comment

You must log in or register to post comments.

Copyright © 2005 Booleansoup.com
Questions? Comments? Bug reports? Contact us!