File: ipc_socket_client.h

package info (click to toggle)
intel-compute-runtime 26.05.37020.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 83,596 kB
  • sloc: cpp: 976,037; lisp: 2,096; sh: 704; makefile: 162
file content (40 lines) | stat: -rw-r--r-- 879 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * Copyright (C) 2026 Intel Corporation
 *
 * SPDX-License-Identifier: MIT
 *
 */

#pragma once

#include "shared/source/os_interface/linux/ipc_socket_server.h"

#include <string>

namespace NEO {

class IpcSocketClient {
  public:
    IpcSocketClient();
    ~IpcSocketClient();

    bool connectToServer(const std::string &socketPath);
    void disconnect();
    int requestHandle(uint64_t handleId);

    bool isConnected() const { return clientSocket != -1; }

  protected:
    int receiveFileDescriptor(void *data, size_t dataSize);

    bool sendMessage(const IpcSocketMessage &msg, const void *payload = nullptr);
    bool receiveMessage(IpcSocketMessage &msg, void *payload = nullptr, size_t maxPayloadSize = 0);

  private:
    int clientSocket = -1;
    std::string serverSocketPath;

    static constexpr int socketTimeout = 5000; // 5 seconds
};

} // namespace NEO