From 27dc0dbf5e72a5755366be045c4874770e92f79c Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Mon, 23 Nov 2015 10:31:52 +0100 Subject: [PATCH] Socket.pm: Add tiny subroutine to drop an existing socket file. This function can be called at any time to release the socket file. Signed-off-by: Stefan Schantl --- modules/Socket.pm | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/Socket.pm b/modules/Socket.pm index cdcca00..5e5a998 100644 --- a/modules/Socket.pm +++ b/modules/Socket.pm @@ -4,7 +4,7 @@ use warnings; use Exporter qw(import); -our @EXPORT_OK = qw(Server Client Message_Parser); +our @EXPORT_OK = qw(Server Client Message_Parser RemoveSocketFile); use IO::Socket::UNIX qw( SOCK_STREAM SOMAXCONN ); @@ -114,4 +114,17 @@ sub Message_Parser ($) { return undef; } +# +## RemoveSocketFile function. +# +## A tiny function which just removes an existing Socket file. +# +sub RemoveSocketFile () { + # Check if a socketfile exists. + if (-e $socketfile) { + # Delete the socket file. + unlink($socketfile); + } +} + 1; -- 2.39.2