/* Offloads close by terminating the connection and freeing the socket.  */
static int offload_close(void *obj)
/* Offloads close by terminating the connection and freeing the socket.  */
static int offload_close(void *obj)
{
	struct modem_socket *sock = (struct modem_socket *)obj;
	if (get_state() != SIM7080_STATE_NETWORKING) {
		LOG_ERR("Modem currently not attached to the network!");
		return -EAGAIN;
	}
	if (modem_socket_is_allocated(&mdata.socket_config, sock) == false) {
		return 0;
	}
	if (sock->is_connected) {
		socket_close(sock);
	}
	return 0;
}