# Send side routines
sub connect {
my ($pkg, $to_host, $to_port, $rcvd_notification_proc) = @_;
# Create a new internet socket
my $sock = IO::Socket::INET->new (
PeerAddr => $to_host,
PeerPort => $to_port,
Proto => 'tcp',
Reuse => 1);
####
use Msg;
...
foreach $prog (@ARGV) {
my $conn = Msg->connect($host, $port,
\&rcvd_msg_from_server);
die "Client could not connect to $host:$port\n" unless $conn;
print "Connection successful.\n";
####
# Create a connection end-point object
my $conn = bless {
sock => $sock,
rcvd_notification_proc => $rcvd_notification_proc,
}, $pkg;
####
sub send_now {
my ($conn, $msg) = @_;
_enqueue ($conn, $msg);
$conn->_send (1); # 1 ==> flush ??????
}
####
$conn->_send (1);
####
_send ($conn,1);