Title: Support Linux Socket connection
Last modified: November 28, 2016

---

# Support Linux Socket connection

 *  Resolved [ddur](https://wordpress.org/support/users/ddur/)
 * (@ddur)
 * [9 years, 6 months ago](https://wordpress.org/support/topic/support-linux-socket-connection/)
 * Fix to handle host defined as `localhost:/var/run/mysql/mysql.sock
 *     ```
           //parse out port number if exists
           $port = 3306;//default
           if(stripos($arr_cfg['db.host'],':')) {
               // port or socket?
               $port = is_numeric($port) && ((0+$port) > 0) && ((0+$port) <= PHP_INT_MAX) ? (0+$port) : null;
               if (is_null($port)) {
                   // sock
                   $port = 3306; //default
               } else {
                   // remove port
                   $arr_cfg['db.host'] = substr($arr_cfg['db.host'], 0, stripos($arr_cfg['db.host'],':'));
               }
           }
       ```
   

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Scott Farrell](https://wordpress.org/support/users/sfarrell5123/)
 * (@sfarrell5123)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/support-linux-socket-connection/#post-8509349)
 * thanks, I’ll check it out.
 * Is that a fix for my code ? what file ? I thought I just talked to the db through
   WordPress db handles.
 *  Thread Starter [ddur](https://wordpress.org/support/users/ddur/)
 * (@ddur)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/support-linux-socket-connection/#post-8510316)
 * Yes, benchmark.php,
 *     ```
       function test_mysql(&$arr_return, $arr_cfg)
       { .....
       ```
   
 *  Plugin Author [Scott Farrell](https://wordpress.org/support/users/sfarrell5123/)
 * (@sfarrell5123)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/support-linux-socket-connection/#post-8517619)
 * I cant see benchmark.php or that test_mysql anywhere in my code.
 *  Thread Starter [ddur](https://wordpress.org/support/users/ddur/)
 * (@ddur)
 * [9 years, 5 months ago](https://wordpress.org/support/topic/support-linux-socket-connection/#post-8519712)
 * I apologize, it is another plugin,
    [https://wordpress.org/plugins/wpperformancetester/](https://wordpress.org/plugins/wpperformancetester/)
 * Thank you

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Support Linux Socket connection’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/wp-hosting-performance-check_ffc8a4.
   svg)
 * [wp Hosting Performance Check](https://wordpress.org/plugins/wp-hosting-performance-check/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-hosting-performance-check/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-hosting-performance-check/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-hosting-performance-check/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-hosting-performance-check/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-hosting-performance-check/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [ddur](https://wordpress.org/support/users/ddur/)
 * Last activity: [9 years, 5 months ago](https://wordpress.org/support/topic/support-linux-socket-connection/#post-8519712)
 * Status: resolved