Hi,

I have a problem with sockets that goes like this..
I want to create a socket and then want to use it at a later time to send messages..
How do I save sockets .? It seems that I can not save "S". S is a constant ... I dont 
know what wrong am I doing..

Can some one help me ????? I need to create many sockets and store them ..

I want my function calls as shown below ..
$sock = perl_client($ip_addr , $port_num);
send_msg($sock, $message);

I used a standard code for socket creation 
****************************************************
sub perl_client {
..
...

$sockaddr = 'S n a4 x8';
$this = pack($sockaddr, AF_INET, 0, $thisaddr);
$that = pack($sockaddr, AF_INET, $port, $thataddr);

if (bind(S, $this)) {
    print "Bind succeeded.\n";
}
else  {
    die $!;
}

if (connect(S, $that)) {
    print "Connect succeeded.\n";
    return S;
}


sub send_msg {
(S, $msg) = @_;

select(S);
$| = 1;

select(STDOUT);

if ($child = fork) {
    
    print S $msg;
    sleep 3;
    do dokill();
}
else {
    while (<$sock>) {
    print "Server: S";
    }
}

}
*****************************************************

Regards
Rajeev

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to