added QSE_NWIO_KEEPALIVE and QSE_NWIO_REUSEADDR

This commit is contained in:
hyung-hwan 2012-05-03 12:57:58 +00:00
parent efdb33cd30
commit 5943d9d190
6 changed files with 32 additions and 7 deletions

View File

@ -127,6 +127,8 @@ enum qse_fio_mode_t
typedef unsigned long qse_fio_hnd_t; typedef unsigned long qse_fio_hnd_t;
#elif defined(__DOS__) #elif defined(__DOS__)
typedef int qse_fio_hnd_t; typedef int qse_fio_hnd_t;
#elif defined(vms) || defined(__vms)
typedef void* qse_fio_hnd_t; /* struct FAB* */
#else #else
typedef int qse_fio_hnd_t; typedef int qse_fio_hnd_t;
#endif #endif

View File

@ -41,6 +41,8 @@ enum qse_nwio_flag_t
QSE_NWIO_TCP = (1 << 9), QSE_NWIO_TCP = (1 << 9),
QSE_NWIO_UDP = (1 << 10), QSE_NWIO_UDP = (1 << 10),
QSE_NWIO_REUSEADDR = (1 << 12),
QSE_NWIO_KEEPALIVE = (1 << 13),
/** do not reread if read has been interrupted */ /** do not reread if read has been interrupted */
QSE_NWIO_READNORETRY = (1 << 14), QSE_NWIO_READNORETRY = (1 << 14),
/** do not rewrite if write has been interrupted */ /** do not rewrite if write has been interrupted */

View File

@ -806,7 +806,7 @@ static qse_ssize_t nwio_handler_open (
handle = qse_nwio_open ( handle = qse_nwio_open (
qse_awk_rtx_getmmgr(rtx), 0, nwad, qse_awk_rtx_getmmgr(rtx), 0, nwad,
flags | QSE_NWIO_TEXT | QSE_NWIO_IGNOREMBWCERR | flags | QSE_NWIO_TEXT | QSE_NWIO_IGNOREMBWCERR |
QSE_NWIO_READNORETRY | QSE_NWIO_WRITENORETRY QSE_NWIO_REUSEADDR | QSE_NWIO_READNORETRY | QSE_NWIO_WRITENORETRY
); );
if (handle == QSE_NULL) return -1; if (handle == QSE_NULL) return -1;

View File

@ -33,7 +33,6 @@ libqsecmn_la_SOURCES = \
env.c \ env.c \
gdl.c \ gdl.c \
htb.c \ htb.c \
lda.c \
fio.c \ fio.c \
fma.c \ fma.c \
fmt.c \ fmt.c \
@ -42,6 +41,7 @@ libqsecmn_la_SOURCES = \
fs-move.c \ fs-move.c \
hton.c \ hton.c \
ipad.c \ ipad.c \
lda.c \
main.c \ main.c \
mbwc.c \ mbwc.c \
mbwc-str.c \ mbwc-str.c \

View File

@ -78,10 +78,10 @@ am__DEPENDENCIES_1 =
libqsecmn_la_DEPENDENCIES = $(am__DEPENDENCIES_1) libqsecmn_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
am_libqsecmn_la_OBJECTS = alg-rand.lo alg-search.lo alg-sort.lo \ am_libqsecmn_la_OBJECTS = alg-rand.lo alg-search.lo alg-sort.lo \
assert.lo chr.lo cp949.lo cp950.lo dll.lo env.lo gdl.lo htb.lo \ assert.lo chr.lo cp949.lo cp950.lo dll.lo env.lo gdl.lo htb.lo \
lda.lo fio.lo fma.lo fmt.lo fs.lo fs-err.lo fs-move.lo hton.lo \ fio.lo fma.lo fmt.lo fs.lo fs-err.lo fs-move.lo hton.lo \
ipad.lo main.lo mbwc.lo mbwc-str.lo mem.lo nwad.lo nwio.lo \ ipad.lo lda.lo main.lo mbwc.lo mbwc-str.lo mem.lo nwad.lo \
oht.lo opt.lo path-basename.lo path-canon.lo pio.lo pma.lo \ nwio.lo oht.lo opt.lo path-basename.lo path-canon.lo pio.lo \
rbt.lo rex.lo sio.lo sll.lo slmb.lo stdio.lo str-beg.lo \ pma.lo rbt.lo rex.lo sio.lo sll.lo slmb.lo stdio.lo str-beg.lo \
str-cat.lo str-chr.lo str-cnv.lo str-cmp.lo str-cpy.lo \ str-cat.lo str-chr.lo str-cnv.lo str-cmp.lo str-cpy.lo \
str-del.lo str-dup.lo str-dynm.lo str-dynw.lo str-end.lo \ str-del.lo str-dup.lo str-dynm.lo str-dynw.lo str-end.lo \
str-excl.lo str-fcpy.lo str-fnmat.lo str-incl.lo str-len.lo \ str-excl.lo str-fcpy.lo str-fnmat.lo str-incl.lo str-len.lo \
@ -309,7 +309,6 @@ libqsecmn_la_SOURCES = \
env.c \ env.c \
gdl.c \ gdl.c \
htb.c \ htb.c \
lda.c \
fio.c \ fio.c \
fma.c \ fma.c \
fmt.c \ fmt.c \
@ -318,6 +317,7 @@ libqsecmn_la_SOURCES = \
fs-move.c \ fs-move.c \
hton.c \ hton.c \
ipad.c \ ipad.c \
lda.c \
main.c \ main.c \
mbwc.c \ mbwc.c \
mbwc-str.c \ mbwc-str.c \

View File

@ -316,10 +316,17 @@ int qse_nwio_init (
goto oops; goto oops;
} }
if ((flags & QSE_NWIO_TCP) && (flags & QSE_NWIO_KEEPALIVE))
{
int optval = 1;
setsockopt (nwio->handle, SOL_SOCKET, SO_KEEPALIVE, (void*)&optval, QSE_SIZEOF(optval));
}
if (flags & QSE_NWIO_PASSIVE) if (flags & QSE_NWIO_PASSIVE)
{ {
qse_nwio_hnd_t handle; qse_nwio_hnd_t handle;
if (flags & QSE_NWIO_REUSEADDR)
{ {
int optval = 1; int optval = 1;
setsockopt (nwio->handle, SOL_SOCKET, SO_REUSEADDR, (void*)&optval, QSE_SIZEOF(optval)); setsockopt (nwio->handle, SOL_SOCKET, SO_REUSEADDR, (void*)&optval, QSE_SIZEOF(optval));
@ -371,10 +378,17 @@ int qse_nwio_init (
goto oops; goto oops;
} }
if ((flags & QSE_NWIO_TCP) && (flags & QSE_NWIO_KEEPALIVE))
{
int optval = 1;
setsockopt (nwio->handle, SOL_SOCKET, SO_KEEPALIVE, (void*)&optval, QSE_SIZEOF(optval));
}
if (flags & QSE_NWIO_PASSIVE) if (flags & QSE_NWIO_PASSIVE)
{ {
qse_nwio_hnd_t handle; qse_nwio_hnd_t handle;
if (flags & QSE_NWIO_REUSEADDR)
{ {
int optval = 1; int optval = 1;
setsockopt (nwio->handle, SOL_SOCKET, SO_REUSEADDR, (void*)&optval, QSE_SIZEOF(optval)); setsockopt (nwio->handle, SOL_SOCKET, SO_REUSEADDR, (void*)&optval, QSE_SIZEOF(optval));
@ -437,11 +451,18 @@ int qse_nwio_init (
} }
#endif #endif
if ((flags & QSE_NWIO_TCP) && (flags & QSE_NWIO_KEEPALIVE))
{
int optval = 1;
setsockopt (nwio->handle, SOL_SOCKET, SO_KEEPALIVE, (void*)&optval, QSE_SIZEOF(optval));
}
if (flags & QSE_NWIO_PASSIVE) if (flags & QSE_NWIO_PASSIVE)
{ {
qse_nwio_hnd_t handle; qse_nwio_hnd_t handle;
#if defined(SO_REUSEADDR) #if defined(SO_REUSEADDR)
if (flags & QSE_NWIO_REUSEADDR)
{ {
int optval = 1; int optval = 1;
setsockopt (nwio->handle, SOL_SOCKET, SO_REUSEADDR, (void*)&optval, QSE_SIZEOF(optval)); setsockopt (nwio->handle, SOL_SOCKET, SO_REUSEADDR, (void*)&optval, QSE_SIZEOF(optval));