in reply to DBI & setsockopt

Hmmm ... the Mysql module can do this:

Database Handle

As said above you get a database handle with the connect() method. The database handle knows about the socket, the host, and the database it is connected to.

You get at the three values with the methods

$scalar = $dbh->sock;
$scalar = $dbh->host
$scalar = $dbh->database;

-derby

Replies are listed 'Best First'.
Re^2: DBI & setsockopt
by fhew (Beadle) on Nov 23, 2005 at 14:12 UTC
    I believe the sock in this context is actually the port number specified in the connect() call, and not the socket used to communicate. Even while trying to debug, I must be doing something stupid. Here's what I'm doing:
    $dbh = &db_connect; print "hi there 3\n"; #my $p = $dbh->sock; #my $h = $dbh->host; #my $d = $dbh->database; #print "port: p\nhost: $h\ndb : $d\n"; print "dbh: $dbh\n"; use Data::Dumper; Data::Dumper->Dump([$dbh]); foreach ( keys %$dbh) { print "$_=$dbh{$_}\n"; } print "got here\n";
    And here's what I get:
    hi there 3 dbh: DBI::db=HASH(0x3de72b0) got here
    a) Its telling me that $dbh is a hash, but why can't I print out its contents?

    b)The 4 lines are commented out, because if I leave them in, the application dies silently.

      Sorry for the confusion, I was talking about the Mysql module not the DBD::Mysql module (they're slightly different).

      -derby