A 35-year-old man will be sentenced next week for killing a 62-year-old man by punching him repeatedly in the head.

Gary Walsh, with an address at The Watercourse, Orwell Park, Templeogue, Dublin pleaded guilty to the manslaughter of Cathal Sweeney in a flat in Terenure, Dublin in February 2014.

The plea was accepted after two juries failed to reach verdicts in two previous murder trials.

In a letter read to the court Walsh said he sincerely apologised to Mr Sweeney's family for what he had done.

The court heard he had made "valiant efforts" to turn his life around.

The court heard Walsh and his victim Mr Sweeney were alcoholics, as was a third man drinking in the flat at Ashdale Gardens in Terenure on 8 February, 2014.

At some stage Walsh was told of an allegation that Mr Sweeney had sexually assaulted another man. He became annoyed that Mr Sweeney was not acknowledging this allegation and punched him six or seven times in the head and face.

Mr Sweeney, who was in bad health, and had a serious liver problem died as a result of his injuries.

Walsh was tried for murder twice but two juries were unable to reach a verdict and the state accepted his plea to manslaughter.

The court heard Walsh had 17 previous convictions for assault and public order offences but had made "valiant efforts" to turn his life around following his release on bail in 2015.

The court was told his life went off the rails when he lost his job six months after the birth of his daughter, and began drinking heavily.

Mr Sweeney's son David told the court that his father was an alcoholic and their relationship with him had never been normal. However, he said alcoholism was an illness. He said his father had met two of his six grandchildren and they had begun forging a new relationship with him through the grandchildren.

He said his father was not a perfect husband or father but he was a good man and it was very hard to accept or understand the circumstances in which he was taken from them.

He said he could not stop thinking about the fear his father must have experienced on the day he was killed and he felt he should have been able to help him.

Mr Sweeney's sister Ann said the excruciating vision of her brother after his death still visited her. She said he was a good looking, kind, strong, big brother. Addiction was a disease she said and should not define him in his untimely death.

Defence Counsel Brendan Grehan said his client had made very serious and concerted efforts to turn his life around and try to give something back.

The court heard testimonials from various individuals and groups about Walsh's volunteering with a hostel for the homeless and a group working with former prisoners.

In a letter, read by Mr Grehan to the court, Walsh said he was working hard to become the man he knew he could be.

He said he fully understood his actions had caused a man to lose his life. He said he felt hurt, pain and remorse and would do anything to take it back. He said he hoped by living well and trying to do the right things he would bring the Sweeney family and his own some comfort.

He said whatever sentence he received he would use it wisely, and he sincerely apologised to the Sweeney family for the pain and sorrow he had caused them.

Mr Grehan said his client wanted to try to right the terrible wrong he had done by trying to make a contribution to others.

Mr Justice Patrick McCarthy said he would impose his sentence next Monday.