Basically what FlameDuck said.
When you wrote this software under contract and did not explicitly reserve your rights, then the code AND the copyright are entirely "his" and you have surrendered all your rights of use and distribution.
Depending on the country you live in, the only possible difference to working as a regular employee for a software company - where everything belongs to the company but not to you - is that you MIGHT still own the copyright. In Germany, for example, you simply cannot lose your copyright (unless you work as an employee, then you never had it). However, you would usually transfer ALL rights of use to the buyer, which basically renders your copyright useless for you. We call this "Urheberrecht", wich rather translates to "creator's right" than "Copyright". Copyright is the official translation, but misleading, since it does not reflect the original meaning but rather represents the rights of use and distribution, which are not the same.
Anyway. You must be VERY specific about your terms and conditions in legally valid and binding written form the next time you take on a project for somebody else and make sure that the contract explicitly covers all your interests.
However, if you don't have the money to sue, then even the best contract would be worthless.
When you wrote this software under contract and did not explicitly reserve your rights, then the code AND the copyright are entirely "his" and you have surrendered all your rights of use and distribution.
Depending on the country you live in, the only possible difference to working as a regular employee for a software company - where everything belongs to the company but not to you - is that you MIGHT still own the copyright. In Germany, for example, you simply cannot lose your copyright (unless you work as an employee, then you never had it). However, you would usually transfer ALL rights of use to the buyer, which basically renders your copyright useless for you. We call this "Urheberrecht", wich rather translates to "creator's right" than "Copyright". Copyright is the official translation, but misleading, since it does not reflect the original meaning but rather represents the rights of use and distribution, which are not the same.
Anyway. You must be VERY specific about your terms and conditions in legally valid and binding written form the next time you take on a project for somebody else and make sure that the contract explicitly covers all your interests.
However, if you don't have the money to sue, then even the best contract would be worthless.