Check-in Number:
|
1484 | |
Date: |
2002-Jan-02 14:35:36 (local)
2002-Jan-02 13:35:36 (UTC) |
User: | rse |
Branch: | |
Comment: |
add support for reusability of address or port |
Tickets: |
|
Inspections: |
|
Files: |
|
ossp-pkg/sa/sa.c 1.47 -> 1.48
--- sa.c 2002/01/02 13:27:11 1.47
+++ sa.c 2002/01/02 13:35:36 1.48
@@ -1143,6 +1143,25 @@
#endif
break;
}
+ case SA_OPTION_REUSEADDR:
+ case SA_OPTION_REUSEPORT: {
+ /* enable/disable reusability of binding to address or port */
+ int mode = ((int)va_arg(ap, int) ? 1 : 0);
+ int flag;
+ if (sa->fdSocket == -1) {
+ rv = SA_ERR_USE;
+ break;
+ }
+ switch (id) {
+ case SA_OPTION_REUSEADDR: flag = SO_REUSEADDR; break;
+ case SA_OPTION_REUSEPORT: flag = SO_REUSEPORT; break;
+ default: flag = 0; break;
+ }
+ if (setsockopt(sa->fdSocket, SOL_SOCKET, flag,
+ (void *)&mode, sizeof(mode)) < 0)
+ rv = SA_ERR_SYS;
+ break;
+ }
case SA_OPTION_NONBLOCK: {
/* enable/disable non-blocking I/O mode */
int flags;
|
|
ossp-pkg/sa/sa.h 1.26 -> 1.27
--- sa.h 2002/01/02 12:43:50 1.26
+++ sa.h 2002/01/02 13:35:36 1.27
@@ -138,6 +138,8 @@
/* list of options */
typedef enum {
SA_OPTION_NAGLE,
+ SA_OPTION_REUSEADDR,
+ SA_OPTION_REUSEPORT,
SA_OPTION_NONBLOCK
} sa_option_t;
|
|
ossp-pkg/sa/sa.pod 1.20 -> 1.21
--- sa.pod 2002/01/02 12:43:50 1.20
+++ sa.pod 2002/01/02 13:35:36 1.21
@@ -435,10 +435,15 @@
the expected following argument(s) are dependent on the particular
option. Currently the following options are implement (option arguments
in parenthesis): C<SA_OPTION_NAGLE> (C<int> I<yesno>) for enabling
-(I<yesno>=C<1>) or disabling (I<yesno>=C<0>) Nagle's Algorithm
-(see RFC898); C<SA_OPTION_NONBLOCK> (C<int> I<yesno>) for enabling
-(I<yesno>=C<1>) or disabling (I<yesno>=C<0>) non-blocking I/O mode (see
-C<O_NONBLOCK> of fcntl(2)).
+(I<yesno>=C<1>) or disabling (I<yesno>=C<0>) Nagle's Algorithm (see
+RFC898); C<SA_OPTION_REUSEADDR> (C<int> I<yesno>) for enabling
+(I<yesno>=C<1>) or disabling (I<yesno>=C<0>) the reusability of
+the address on binding (see C<SO_REUSEADDR> of setsockopt(2)),
+C<SA_OPTION_REUSEPORT> (C<int> I<yesno>) for enabling (I<yesno>=C<1>)
+or disabling (I<yesno>=C<0>) the reusability of the port on binding
+(see C<SO_REUSEPORT> of setsockopt(2)), C<SA_OPTION_NONBLOCK> (C<int>
+I<yesno>) for enabling (I<yesno>=C<1>) or disabling (I<yesno>=C<0>)
+non-blocking I/O mode (see C<O_NONBLOCK> of fcntl(2)).
Example: C<sa_option(sa, SA_OPTION_NONBLOCK, 1);>
|
|