Audacity 3.2.0
Public Member Functions | Private Attributes | List of all members
IPCClient::Impl Class Referencefinal
Collaboration diagram for IPCClient::Impl:
[legend]

Public Member Functions

 Impl (int port, IPCChannelStatusCallback &callback)
 

Private Attributes

std::unique_ptr< BufferedIPCChannelmChannel
 

Detailed Description

Definition at line 24 of file IPCClient.cpp.

Constructor & Destructor Documentation

◆ Impl()

IPCClient::Impl::Impl ( int  port,
IPCChannelStatusCallback callback 
)
inline

Definition at line 29 of file IPCClient.cpp.

30 {
31 auto fd = socket_guard { socket(AF_INET, SOCK_STREAM, IPPROTO_TCP) };
32 if(!fd)
33 throw std::runtime_error("cannot create socket");
34
35#if defined(__unix__) || defined(__APPLE__)
36 auto fdFlags = fcntl(*fd, F_GETFD, 0);
37 if(fdFlags != -1)
38 fcntl(*fd, F_SETFD, fdFlags | FD_CLOEXEC);
39#endif
40
41 sockaddr_in addrin {};
42 addrin.sin_family = AF_INET;
43 addrin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
44 addrin.sin_port = htons(static_cast<uint16_t>(port));
45
46 if(connect(*fd, reinterpret_cast<const sockaddr*>(&addrin), sizeof(addrin)) == SOCKET_ERROR)
47 {
48 callback.OnConnectionError();
49 return;
50 }
51
52 mChannel = std::make_unique<BufferedIPCChannel>();
53 mChannel->StartConversation(fd.release(), callback);
54 }
virtual void OnConnectionError() noexcept=0
Called when connection attempt fails.
std::unique_ptr< BufferedIPCChannel > mChannel
Definition: IPCClient.cpp:26
RAII-style socket wrapper. Since socket is closed on wrapper destruction, initializing multiple guard...
Definition: socket_guard.h:24
#define SOCKET_ERROR
Definition: ipc-types.h:29

References mChannel, IPCChannelStatusCallback::OnConnectionError(), and SOCKET_ERROR.

Here is the call graph for this function:

Member Data Documentation

◆ mChannel

std::unique_ptr<BufferedIPCChannel> IPCClient::Impl::mChannel
private

Definition at line 26 of file IPCClient.cpp.

Referenced by Impl().


The documentation for this class was generated from the following file: