---
name: "mysql_get_socket"
section: "3"
platform: "linux"
package: "mariadb"
version: "13.0.2-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/mysql_get_socket"
---

# mysql\_get\_socket(3)

### Name

mysql\_get\_socket - Returns the descriptor of the socket used for the current connection

### Synopsis

-

  ```
  #include <mysql.h>
  my_socket mysql_get_socket(MYSQL * mysql);
  ```

### Description

Returns the descriptor of the socket used for the current connection.

### Parameter

- •

  `mysql` - a mysql handle, which was previously allocated by **[mysql\_init(3)](/mysql_init/3.md)** and connected by **[mysql\_real\_connect(3)](/mysql_real_connect/3.md)**.

### Return value

A socket handle or INVALID\_SOCKET (-1) if the socket descriptor could not be determined, e.g. if the connection doesn’t use a socket connection.

### See also

- •

  **[mysql\_real\_connect(3)](/mysql_real_connect/3.md)**
