stream_connect
Connects to a listening stream referenced by the given URI.
Description
This function connects to a listening stream referenced by the given URI. The URI specifies the protocol, address, port and options associated with the stream. The Stream API uses the protocol to load a protocol-specific driver. For example:
tcpip://remotehost:17000 |
- |
connect to remotehost on port 17000 using TCP/IP |
shmem://mymemory:1?bufsize=8192 |
- |
connect via an 8K shared memory buffer |
pipe:mypipe?bufsize=4096 |
- |
connect via a 4K named pipe |
If the non_blocking flag is set to false (0), then this function will block until the connection is made.
If the non_blocking flag is set to true (1), then this function will not block. If the connection cannot be completed immediately then -QERR_WOULD_BLOCK is returned. In this case, the connection may be completed using stream_poll with the STREAM_POLL_CONNECT flag.
Prototype
t_error stream_connect(const char * uri, t_boolean non_blocking, t_int send_buffer_size, t_int receive_buffer_size, t_stream * client_stream);
Parameters
const char * uri
A URI indicating the listening stream to which to connect.
t_boolean non_blocking
Set to true (1) to make the client connection non-blocking.
t_int send_buffer_size
The size of the buffer to use for sending data over the stream, in bytes.
t_int receive_buffer_size
The size of the buffer to use for receiving data over the stream, in bytes.
t_stream * client_stream
A pointer to a t_stream variable in which the client stream handle will be stored.
Return value
Returns 0 on success. If an error occurs then a negative error code is returned.
Error codes
QERR_WOULD_BLOCK
The connection request would block.
Requirements
Include Files |
Libraries |
---|---|
quanser_stream.h |
quanser_communications.lib;quanser_runtime.lib;quanser_common.lib |
Examples
const char uri[] = "shmem://foobar:1"; const t_boolean nonblocking = false; const t_int send_buffer_size = 8000; const t_int receive_buffer_size = 8000; t_stream client; result = stream_connect(uri, nonblocking, send_buffer_size, receive_buffer_size, &client); if (result == 0) { ... }
See Also
Copyright ©2024 Quanser Inc. This page was generated 2024-10-17. Submit feedback to Quanser about this page.