Simple #UDP/IP client/server in C#

December 13, 2018 Leave a comment



You can grab the code for this demo here

Internet traffic can be thought of as layers, normally the stack for viewing a website is IP at the bottom, TCP/IP in the middle, and HTTP at the top.

IP just gets data from A to B , TCP/IP makes sure that data doesn’t get jumbled or dropped in between, and HTTP does things specific to serving websites, like HTTP redirects, HTTP error messages etc.

But, instead of TCP/IP you can also use UDP/IP or simply “UDP”, which is TCP’s messy little brother. It still has the concept of ports like TCP has, but offers no guarantee of jumbled or dropped data.

For this reason, UDP is only used in situations where low latency is much more important than data integrity, like audio / video streaming or gaming. It’s terrible for file transfer.

One other key use of UDP is it’s lower bandwidth usage, which makes it useful for IOT applications over expensive mobile data networks.

If you want to read more about Network programming, check out my book- which you can Buy at Amazon US or Buy at Amazon UK


Categories: Uncategorized

‘Promise’ is undefined #IE11

December 10, 2018 Leave a comment


Javascript promises are a key feature of modern asyncronous javascript, but, if you’re developing a mass-market website, cross-browser support may trump the syntactical sugar, especially if you’re facing down business-types, rather than other developers.

Specifically, IE11 does not support Javascript promises, and if you are looking to support a wide range of browsers, then there is a polyfill available from Taylor Hakes, that can get round that error message, that simply says “‘Promise’ is undefined” in IE11

So, working with an example from SMTPJS v3 – which now uses promises, and arrow functions, you need include the following script tags;

Then adjust the code to use an inline function instead of an arrow function:

Host : “”,
Username : “******”,
Password : “*****”,
To : ‘’,
From : “”,
Subject : “This is the subject”,
Body : “My useragent is ” + navigator.userAgent
function(message) { alert(message) } // FOR IE

Categories: Uncategorized

#SMTPJS now supports multiple attachments, ReplyTo and sender name

December 7, 2018 1 comment


In case you’ve missed it, has just released the V3 Library, this offers a cleaner object model, promises, and new features, such as multiple attachments, Reply-to, and sender name

Here’s an example on how to send multiple attachments:

To : “”,
From : “”,
FromName: “Joe Sender”,
ReplyAddress: “”,
Subject : “This is the subject”,
Body : “This is the body”,
Attachments : [
name : “padlock.png”,
path : “”
name : “spam.png”,
path : “”
message => alert(message)

Obviously, you need to change the secureToken property above, or pass in naked SMTP credentials.

Here’s another example, imagine you want to offer an upload form, so people can upload a file to be sent to you – without putting the file on your server.

First, here’s the required line of HTML:

<input type=”fileid=”fileuploadonchange=”uploadFileToServer()” />

Then here’s the uploadFileToServer() method;

function uploadFileToServer() {
var file = event.srcElement.files[0];
var reader = new FileReader();
reader.onload = function () {
var datauri = “data:” + file.type + “;base64,” + btoa(reader.result);
To : “”,
From : “”,
Subject : “The subject”,
Body : “See file attached”,
Attachments : [
name :,
data : datauri
message => alert(message)
reader.onerror = function() {
console.log(‘there are some problems’);

Categories: Uncategorized

Support for #Motorcycle registration lookups in #Spain via #API

December 5, 2018 Leave a comment


Need to find vehicle details of a motorcycle registered in Spain via an API?, this new addition to our suite lets you do this; you should use an alternative API endpoint, as follows;

Which returns data in the following format:


 “Description”: “SUZUKI DL 650 V-STROM”,

 “CarMake”: {

   “CurrentTextValue”: “SUZUKI”


 “CarModel”: {

   “CurrentTextValue”: “DL 650”


 “MakeDescription”: {

   “CurrentTextValue”: “SUZUKI”


 “ModelDescription”: {

   “CurrentTextValue”: “DL 650”


 “EngineSize”: “645”,

 “VehicleIdentificationNumber”: “”,

 “RegistrationYear”: “2003”,

 “RegistrationDate”: “01/11/2003”,

 “Variation”: “V-STROM”,

 “Seats”: 1,

 “VariantType”: “”,

 “VehicleType”: “MOTOCICLETA”,

 “Fuel”: “GASOLINA”,

 “IndicativePrice”: “7909.79”,

 “Doors”: 0,

 “AllTerain”: 0,

 “KType”: 0,

 “ImageUrl”: “;,

 “Transmission”: “MANUAL”,

 “DynamicPower”: “68”,

 “Stolen”: null


Categories: Uncategorized

A simple change to make your website #IPv6 ready.

November 29, 2018 Leave a comment


Making your website accessible by both IPv4 (What everyone is familiar with) and IPv6, those wierd long IP addresses with hex numbers in them, is as simple as

(1) finding your IPv6 address, which you can do by doing a IPConfig /all on your desktop

And getting the IPv6 address from the “6TO4 adapter”

Tunnel adapter 6TO4 Adapter:

Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Microsoft 6to4 Adapter
Physical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
IPv6 Address. . . . . . . . . . . : 2002:5f9a:f46a::5f9a:f46a(Preferred)
Default Gateway . . . . . . . . . : 2002:c058:6301::1
DHCPv6 IAID . . . . . . . . . . . : 469762048
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-21-42-14-1B-00-25-90-1E-04-94

(2) Then adding a DNS entry for an AAAA record pointing to the IPv6 address that you found above.

I doubt it will make much difference today or tomorrow, since IPv4 will take a long long time to die out completely, but slowly, IPv6 will become the norm, and it’s best to be ahead of the curve, rather than being behind it.



Categories: Uncategorized

Run #ASP.NET on #Ubuntu using .NET Core

November 27, 2018 Leave a comment

Screenshot 2018-11-27 at 10.54.01

Yes, it’s possible to host ASP.NET on linux, and there are plenty of great tutorials out there, and this is just a quick post with a few of my tips thrown in…

I followed the tutorial at, using a EC2 instance from Amazon.

However, at the point where it says, “point a browser at https://localhost:5001&#8221; I had to get a bit inventive,

So, I opened up port 5001 in security settings, and I created a release build

dotnet build –configuration Release

Navigated to the “publish” folder and ran this command to have the app listen on all hosts, not just localhost.

dotnet myWebAppp.dll –urls

Then from my mac, I could navigate to https://%5BIP%5D:5001, and dismissed the bad cert warning.

Categories: Uncategorized

Get the #Google #avatar image from an email address in #PHP

November 26, 2018 Leave a comment

Screen Shot 2017-08-12 at 16.49.24

This example uses the service, but a new JSON based API which is a bit more modern than the XML / SOAP based API.

$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_USERPWD => “arnoldtest:test123″
$resp = curl_exec($curl);
$avatar = json_decode($resp);

<img src=”<?php echo $avatar->Image ?>”><br>
<?php echo $avatar->Name ?>


The username and password should be substituted with your own username/password which is available at the website.


Categories: Uncategorized