One way I can think of would be to have your program check for the lock file when it starts. If one doesn't exist, it creates it. Inside the lock file you could store a randomly-generated string to act as a password. If it does exist then it could connect via a socket and send the password that was in the lock file as security credentials along with the string you want to send.
So the first instance of your program starts. It creates the lock file, generates the password, and stores it in the lock file. A second instance of your program starts and finds the lock file. It reads the password in from the file, connects to whatever port the first instance of your program is listening to and then sends the password from the lock file and then whatever information you want. The first instance of your program checks the supplied password against the password it generated. If they match, it accepts the message from the second instance of your program.
You'd make it so the lock file was only readable by the whoever owned your program. Your program could check this before trying to send the message. That way you (and only you) could also create little helper programs to send messages to your program also, but other users wouldn't be able to read the password.
The password you generate could be of variable length too, so it should be pretty secure. How long would it take your computer to guess a string that's somewhere between 250 and 500 characters long when each character could be 1 of 50-ish different symbols? You wouldn't even have to stick to ASCII. So the password could be made where each symbol could be 1 through 255. I'm no math whiz, but I'm guessing it would be pretty difficult