- // Set up listening socket
- int lfd = fsp::socket(AF_UNIX, SOCK_STREAM, 0);
- ASSERT_NE(lfd, -1);
- SCOPE_EXIT { close(lfd); };
- ASSERT_NE(bind(lfd, (struct sockaddr*)&addr, sizeof(addr)), -1)
- << "Bind failed: " << errno;
-
- // Create the connecting socket
- int csd = fsp::socket(AF_UNIX, SOCK_STREAM, 0);
- ASSERT_NE(csd, -1);
-
- // Listen for incoming connect
- ASSERT_NE(listen(lfd, 5), -1);
-
- // Connect to the listening socket
- ASSERT_NE(fsp::connect(csd, (struct sockaddr*)&addr, sizeof(addr)), -1)
- << "Connect request failed: " << errno;
-
- // Accept the connection
- int sfd = accept(lfd, nullptr, nullptr);