Non blocking sockets

Watched quite a heavy film last night so didn’t start the day with bells and whistles. Anyway, back on with Java, today’s task really was just to complete my conversion of my server code from C++. Spent the bulk of the day on the server side TCP handling. I’m not going for SSL straight away as that’s just going to complicate things. Now the usual way of doing this is to either create a number of threads and then each one of them listens on a socket and then creates a client or to have a main thread that listens and then create threads as new connections come in. Talking to the guys it appears there is another way to do it in Java. It uses a ‘Selector’, so what you do is set up a socket stream and then set that no non-blocking. You then create a selector and add the socket to it and tell it you want it to monitor ‘accept’. Then you just sit in a loop iterating over this selector array. On accepts you just create the client socket and say you want to monitor read and write. Reads are fairly straight forward, writes I’m not so sure about yet as normally output shouldn’t be blocked, but I’m thinking if writes are suddenly unavailable then may be this is good way of checking for disconnections. Anyway, got it all as far as running and accepting a connection and then crashing, but that’s a job for another day. Not sure how much more time I’ll be allowed to spend on it, but if I’m given a couple more days then I think I’ve pretty much got the new language mastered.

Other activities, well not a great deal. Walked the dog as it’s my turn on Friday’s. She was actually really good. I took some biscuits with me and rewarding her when she didn’t try and declare war on other dogs. Went to the gym and did pump. Now I think it’s time to shutdown, both the machine and myself.

Today I learnt the rest of Java

So started as I left yesterday, but as I didn’t sleep well last night I set myself a bit of a challenge to do with callbacks. Had an idea about how to solve them using interfaces and thankfully worked it out with no Googling. Then it was very much the case of working through the rest of the tutorial. So covered threads and syncronisation, streams and a few security type things.

It’s Jamie’s turn to walk the dog so I went cross country running. New compression tights arrived today, so wore them for the run and kept them on until this evening. Must admit I’ve had no muscle ache at all so they do a good job. Jamie still hasn’t walked the dog.

After I finished the tutorial I decided to try and convert the server side of the client / server app I was working on last week into Java. Certainly a learning experience, no problems so far and has been very interesting.

Last night there was a brewing ‘incident’. The airlock on the big brew barrel decided not to work and it blew the lid clean off with a hell of an explosion. The good news is none of the actual brew escaped. Managed to fix the lid and replace the airlock, dropped the temperature a bit and now it’s all bubbling nicely. Unlike the strawberry wine which seems to be fizzing a bit, but nothing in the way of major carbon dioxide. It’s meant to be ready in three weeks, it’s done about two, I reckon it’s going to need about six before the gravity drops. Still the big barrel should be done by about Tuesday.

So more of the same tomorrow, which I’m quite looking forward to. I think I need to get an iPod/iPad dock as trance from the iMac speakers is just shit.

It’s torture porn night, but tonight’s film isn’t the usual horror, I think it’s a bit of a thriller.

And today I learnt Java

Early start today, dog off to play group. She was so excited so didn’t even eat her breakfast. I was beautifully presented with a pile of piss on the kitchen floor though, I think it was the dog, I have no recollection of doing it.

Then it was back to Java, well rather C++ interfacing to Java both ways. Java calling a Windows DLL caused me a few issues but got there in the end. C++ calling Java on the other hand worked first time. I have a good understanding of it now, not sure if it will ever be used, but you never know when your suddenly going to be presented with a C only lib that you need to call from a Java server app. If I am, at least I know how to do it now.

Rang the cleaners, they were coming in about an hour, so went went out for a run of ‘about an hour’. Got back just before they arrived. I must say my Dyson is more effective than their Henry. I think the fine art of ‘rubbing your trainer over the carpet to lift the dog hair’ leaves something to be desired. Anyway, cleaning done, house now tidy.

So then spent the rest of the day into the evening learning Java. From classes, instantiation and initialision, all the way through system resources and exception handling. Must admit, like what I’ve seen so far, all makes sense. Still got a lot to cover, but I imagine I’ll have it all nailed by tomorrow. Learning a new language in a day, no problem, but then again I’ve been doing it for 27 years so I’ve kind of got the hang of it by now.

Picked up dog. She’s picked up a war wound off a bush. She’ll live. House now dirty again.

I’ve done my exercise for the day, so think I may just have a sit down now.

And then I made wine

So started off continuing with the SSL client / server. Then found out I was being re-deployed. So spent up to lunchtime just finishing off what I was doing and archiving it off.

It’s Tuesday so Jamie’s turn to walk the dog, so I went out for a run. Was tiring but good fun.

Came back, now I’m part of the online server team. Something I haven’t done before, but grab it by the horns and try and learn something new. I’m going into it with an open mind, but a ton of bitterness, see how it goes. Ended up trying to do bits in Java, I seem to have been there before on Android.

Anyway, spent the evening then sterilising all my wine making kit. Then made my 30 bottle wine kit. Well it’s in the spare room brewing. Will see how it all goes.

More OpenSSL

So today started with a bit of an oddity, I may be re-deployed on something else, but that isn’t clear yet, so back on with what I was doing. So it was secure socket layer or SSL as it’s known. I’m using OpenSSL as I said before. I had the client up and running but now it was time to do the server. After a bit more research I decided to basically use the existing socket architecture rather than using ‘BIOs’ which is OpenSSL I/O stuff. This means that SSL is built on top the normal socket layer. Also means there are less changes. Although the way it works is a bit strange with data streaming in and out. You bind your socket as normal, but then you have to set it to non-blocking. You then do a dummy read, if that returns ‘need more data’ then you then use ‘select’ as normal to detect if there is any data on the socket, you then do the read again when there is. Write is also similar, you do the write and it may request to wait for output to flush or for input to flush. Yes, both read and write can both request read and write data on the socket. This is because re-negotiation may take place. So it’s a little bit backwards, but fairly easy to understand. Got all that working without too much of a problem.

My turn to take the dog for a walk, so she got a good hour. Then it was back to client side again. So I set that up as non-blocking and had to do a couple of adjustments to get it to respond to ‘is message ready’, basically you have to do a peek rather than a read, then do a pending call, that will tell you then if you need to do a read. I left the actual client code all blocking as the TCP client code before was. It would be fairly easy to change that to non-blocking now though.

Went to the gym and did Body Combat, great fun, busy class, busy car park. Then it was server encryption. Set up the server so it only does strong encryption and supports DH key exchange. This uses a few callbacks, but again was fairly simple to implement.

Not sure how much further I’m going to take this now, will probably just end up adding a bit of error checking and that will be it. Will find out tomorrow.

And now for the next Christmas dinner

So we started off today in bed watching ‘Splash’ which is this new ITV show thing about Z list celebrities learning to dive. The good thing it has Tom Daley with speedo’s on. The bad it’s far too long and just a little bit shite.

We then had to go out and get Christmas presents for Jamie’s Dad and Grandad as it was time for the next Christmas dinner. So off we went to Cribb’s and got various booze related gifts and a photo hastily printed off at Asda. Got back home just in time to let the dog out for a piss and go out again.

It was okay I guess, even if the conversation was somewhat laboured at times. It’s quite difficult to hold a conversation with someone you have nothing at all in common with, you only see about once a year and don’t really care too much about what they are doing anyway. Always nice to see Jim though (Jamie’s grandad), have a lot of time for him, very interesting and amusing bloke, especially after he’s had a few.

So came back from there and stuck all the Christmas stuff back into the loft. That’s finally all that over for another year. Then did the accounts. I was hoping to do my wine kit, but if all goes according to plan with gym/running/dog walking that should be a job for Tuesday evening.

Still, guess what time it is…I’ll pour the wine.

There’s something quite satisfying about bashing a radiator with a rubber mallet

Busy day today so started fairly early for a Saturday. Took the dog out for a walk. Then I called in to do a home check that I didn’t have a phone number for, thankfully they were in. Then I had another home check right near home. After that it was off to Tesco’s to do the shopping.

Came back, had a light lunch, then off to Screwfix in Yate to pick up a load of heating chemicals. Then from there it was off to another home check the other side of the city. Annoyingly passing another Screwfix on the way. It was all cats today.

So came back and started to clean out the feed and expansion tank. In the end I bailed it out using a cup. Got rid of all the water then gave it a good scrub and disinfect. Then I attached a hose to the drain valve, shoved the dog in the garden and put the hose out the front door. Opened the cock and just let water flow through the system for a bit. After that I tied up the ballcock in the tank and drained down the system. I then refilled it with Sentinel X800, which is a sludge clearer. I turned the pump on high and fired up the system. I left it for about ten minutes with all the radiator valves open. Then in turn I opened one radiator at a time and beat the crap out of it with a rubber mallet wrapped in a towel. After I finished the upstairs I shut the system down and opened up the Magnaclean. That was absolutely full. So cleaned the filter out and did all the downstairs radiators the same way. Drained the system down again and then cleaned the filter once again, which was full. Finally then refilled the system with Sentinel X400 which is another sludge cleaner but this one you leave in the system for four weeks. So I’m leaving this one with all the valves open and the pump on full for the next month, hopefully that will get shot of the rest of the sludge and it will behave itself without gurgling at me.

Oh, just in time for a bath. May be some wine. People moan that draining down and refilling a central heating system takes ages…I’ve done it twice in an evening.

OpenSSL and the joys of secure sockets

So started the day by not feeding the dog. Jamie actually did it before he went to work.

Still working mainly on state machine stuff today, then set up the project to run client/server. Okay, it was running client/server in the same app using local host but it was going through all the motions. That all works fine, okay, no error checking of any kind, but worked as expected.

Lunch time I went for a run, much to the dogs disappointment.

This afternoon I’ve been looking at SSL as this project requires a secure client/server connection. My servers are all set up using SSL certificates so I’ve been here before. But this is the first time I’ve looked at it from an API perspective. I looked at a few libs, but in the end OpenSSL is really the only complete one with all the security up to date. Managed to find pre-compiled windows bins for the latest version, that saved a lot of buggering about. Got it connecting to Google via HTTPS and even my own server, can get the certificate, verify it and looked at various bits of it’s contents. There seems to be some buggering about in hyperspace you need to do to replace the ‘select’ calls for blocking sockets, it get’s complicated with re-negotiation but I think I’ve worked it out. Also the server side I haven’t looked at at all yet, again, it’s interesting stuff, I’m learning something new for sure.

Went to the gym, did Body Pump. Came back, I fed the dog.

Jamie has come home from work, put the washing away, did the dishes and filled the dishwasher. He even says he’s going to take the dog for a walk. May be my bit of sulking worked after all. We have Christmas dinner at his dads on Sunday, a shame I was looking for a quiet weekend. Never mind. Bath O’Clock.

Okay, So maybe I am in life to be walked all over

So started back on the math of yesterdays work. Soon moved on to a second lot, still quite interesting stuff, can’t say any more.

It was Jamie’s day off. I asked him to empty the dishwasher at 9am. It’s now 11:30pm, still hasn’t been looked at.

I walked the dog, went to the gym. Came back, still no dishwasher action. Before I went to the gym I asked him to feed the dog, she’s now walking around hungry.

I’m sat here wondering why the lounge is covered in LED balloons. Their packet is dumped on the cutting board in the kitchen. On top the lizard tank is a cup cake wrapper that’s been their a couple of days, there’s a cup on the table that’s only done a day though. The box the cup cakes were in was emptied yesterday and is now still sat on top of the cooker. There are also a variety of discarded plastic bags and various contents spread across the kitchen. The lights in the lounge have all been moved around and dumped. There’s still a giant pile of clothes in the bedroom. I live with a complete slob who appears to have little in the way of respect for me or the house. I’m no longer going to feed or walk the dog, that’s now Jamie’s responsibility. Which means she will probably die. Which is a shame as I quite liked that dog. I’m going to bed.

Is it a national emergency? No, it’s just you’re laptop didn’t boot

So back to work today. Started off rather early though with Sasha going back to doggy daycare. She got all excited when I got up for a pee at 4am, she had to wait until 6:30. Back in bed by 7am. I didn’t start work until about mid morning, didn’t sleep well last night.

Lunch time came along so I went for a full hour’s cross-country run through lots of sticky mud. It was great fun, a light drizzle, enough to keep you cool. Came back and ate snack size sausage rolls. I think I’m going to be eating left over crap for the next couple of weeks.

Got heavily into work, it’s very math based at the moment and still all proof of concept, nothing to look at here, move along.

Then the phone started ringing….It was Holly Hedge, that was fine, home check for a couple of cats. Then it rang again, it was my mother, not on a work day please. Didn’t answer. Five minutes later, rang again. Then she rang my mobile, then she rang it again and left a message. I listened to the message, apparently her laptop didn’t boot and it’s come up with a message. Then she sent me a text message “urgent, phone me”. There is a thing called ‘cry wolf’ and unfortunately she’s done it far, far too many times. You don’t phone me four times in a row and send me ‘urgent’ text messages during the working day just because you’re laptop didn’t boot the first time. You don’t leave me two messages at 8am because your curtain rail has come off the wall. One day you’re gonna fall down the steps or have an accident and you won’t be able to get hold of anyone because your definition of ‘urgent’ isn’t the same as anyone elses. I picked the dog up.

I carried on with work and finished mid evening. Didn’t need to go to the gym due to the running earlier. Watched some more Christmas TV, I’ve got more of that than crap food to get through.