7 /* connect to stream listener
9 /* #include <connect.h>
11 /* int stream_connect(path, block_mode, timeout)
16 /* stream_connect() connects to a stream listener for the specified
17 /* pathname, and returns the resulting file descriptor.
21 /* Null-terminated string with listener endpoint name.
23 /* Either NON_BLOCKING for a non-blocking stream, or BLOCKING for
24 /* blocking mode. However, a stream connection succeeds or fails
27 /* This argument is ignored; it is present for compatibility with
28 /* other interfaces. Stream connections succeed or fail immediately.
30 /* The result is -1 in case the connection could not be made.
31 /* Fatal errors: other system call failures.
35 /* The Secure Mailer license must be distributed with this software.
38 /* IBM T.J. Watson Research
40 /* Yorktown Heights, NY 10598, USA
47 #ifdef STREAM_CONNECTIONS
57 /* Utility library. */
62 /* stream_connect - connect to stream listener */
64 int stream_connect(const char *path
, int block_mode
, int unused_timeout
)
66 #ifdef STREAM_CONNECTIONS
67 const char *myname
= "stream_connect";
72 * The requested file system object must exist, otherwise we can't reach
75 if ((fifo
= open(path
, O_WRONLY
| O_NONBLOCK
, 0)) < 0)
79 * This is for {unix,inet}_connect() compatibility.
81 if (block_mode
== BLOCKING
)
82 non_blocking(fifo
, BLOCKING
);
85 * Create a pipe, and send one pipe end to the server.
88 msg_fatal("%s: pipe: %m", myname
);
89 if (ioctl(fifo
, I_SENDFD
, pair
[1]) < 0)
90 msg_fatal("%s: send file descriptor: %m", myname
);
94 * This is for {unix,inet}_connect() compatibility.
96 if (block_mode
== NON_BLOCKING
)
97 non_blocking(pair
[0], NON_BLOCKING
);
105 * Keep the other end of the pipe.
109 msg_fatal("stream connections are not implemented");