| 7 | // Builds a connection to /tmp/unixsocket and sends/receives data using it. |
| 8 | |
| 9 | int main(void) { |
| 10 | using libsocket::unix_stream_client; |
| 11 | using std::string; |
| 12 | |
| 13 | string path = "/tmp/unixsocket"; |
| 14 | char* answer = new char[128]; |
| 15 | |
| 16 | memset(answer, 0, 128); |
| 17 | |
| 18 | try { |
| 19 | unix_stream_client sock(path); |
| 20 | |
| 21 | sock.snd("Hello World!\n", 13); |
| 22 | sock.rcv(answer, 127); |
| 23 | |
| 24 | std::cout << answer; |
| 25 | } catch (const libsocket::socket_exception& exc) { |
| 26 | std::cerr << exc.mesg; |
| 27 | } |
| 28 | |
| 29 | return 0; |
| 30 | } |