I don't know you're platform but I wanted to do this in MacPerl.
Perl has an Open function function for sockets but at least in MacPerl the
status wasn't being updated until I tried to send some data on the socket.
The syswrite function will return undef if the connection is lost. I added
code to my server to periodically send a null character to test the socket.
I've now ported my system to Mac OS X Server. Seems that everything that
worked in MacPerl still works in OS X and OS X fixes a few problems that
MacPerl including some important ones like process forking and connection
queueing.
Hope this helps.
Bob Rice
[EMAIL PROTECTED] wrote:
> Hi
>
> I have two problems.
> First, there's a common socket. How can i test in perl, if a socket is
> closed (tcp)? Is there a function for it. I've read the manual, but i found
> nothing.
>
> The second:
> I have an opened socket, connected to a server (tcp). It sends something
> like:
>
> socket(CGSPSERVER, AF_INET, SOCK_STREAM, $proto) || die;
> my $oldfh = select(CGSPSERVER); $| = 1; select($oldfh);
> if (!connect(CGSPSERVER,$sock_peer)) { die; };
> send(CGSPSERVER,$ipc_cmd1,0);
>
> and want to receive an answer:
> while ($line = <CGSPSERVER>)
> {
> push(@answer, $line);
> }
>
> But it doesn't work, and a don't know why. The same server with other
> clients works (it sends back a text). What can be the problem?
>
> in advance
> Thanks for your help
> Hodossy