---
name: "modbus_get_socket"
section: "3"
platform: "linux"
package: "libmodbus-dev"
version: "3.1.6-2.1"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/modbus_get_socket"
---

# modbus\_get\_socket(3)

get the current socket of the context

## NAME

modbus\_get\_socket - get the current socket of the context

## SYNOPSIS

**int modbus\_get\_socket(modbus\_t \****ctx***);**

## DESCRIPTION

The **modbus\_get\_socket()** function shall return the current socket or file descriptor of the libmodbus context.

## RETURN VALUE

The function returns the current socket or file descriptor of the context if successful. Otherwise it shall return -1 and set errno.

## SEE ALSO

[**modbus\_set\_socket**(3)](/modbus_set_socket/3.md)

## AUTHORS

The libmodbus documentation was written by Stéphane Raimbault \<stephane.raimbault@gmail.com\>
