summaryrefslogtreecommitdiff
path: root/doc/xs_setctxopt.txt
blob: ccdd2db3d6de3d35c5b926bdb1d83d088a140477 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
xs_setctxopt(3)
===============


NAME
----

xs_setctxopt - set Crossroads context options


SYNOPSIS
--------
*int xs_setctxopt (void '*context', int 'option_name', const void '*option_value', size_t 'option_len');*


DESCRIPTION
-----------
The _xs_setctxopt()_ function shall set the option specified by the
'option_name' argument to the value pointed to by the 'option_value'
argument, for the Crossroads context pointed to by the 'context' argument.
The 'option_len' argument is the size of the option value in bytes.

CAUTION: Context options take effect only if set with _xs_setctxopt()_
prior to creating the first socket in a given 'context' with _xs_socket()_.

The following options can be set with the _xs_setctxopt()_ function:


XS_MAX_SOCKETS: Set maximum number of sockets
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The 'XS_MAX_SOCKETS' option shall set the maximum nuber of sockets that can
be simultaneously active in the given 'context'.

[horizontal]
Option value type:: int
Option value unit:: sockets
Default value:: 512

XS_IO_THREADS: Set number of worker threads
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The 'XS_IO_THREADS' option shall set the size of the thread pool created by
the given 'context' to handle I/O operations. The minimum value for this
option is `1`.

[horizontal]
Option value type:: int
Option value unit:: threads
Default value:: 1

RETURN VALUE
------------
The _xs_setctxopt()_ function shall return zero if successful. Otherwise it
shall return `-1` and set 'errno' to one of the values defined below.


ERRORS
------
*EINVAL*::
The requested option _option_name_ is unknown, or the requested _option_len_ or
_option_value_ is invalid.
*EFAULT*::
The provided 'context' was invalid.

EXAMPLE
-------
.Setting the number of I/O threads for a context to four.
----
void *context = xs_init ();
int io_threads = 4;
rc = xs_setctxopt (context, XS_IO_THREADS, &io_threads, sizeof (io_threads));
assert (rc == 0);
/* The above call MUST be called before any socket is created in context */
void *socket = xs_socket (context, XS_PUB);
----

SEE ALSO
--------
linkxs:xs_init[3]
linkxs:xs[7]


AUTHORS
-------
The Crossroads documentation was written by Martin Sustrik <sustrik@250bpm.com>
and Martin Lucina <martin@lucina.net>.