in reply to FIle transfer using sockets

$file1=$_;#This should collect the filename send by client right?

No. Nothing is being assigned anything to $_. You'll need to read it from $conn. You'll also have to provide a mechanism to indicate when the end of the file name is reached. Without that, you won't know when to stop reading.

Why are you reinventing HTTP?