From 5943d9d190d55dd8a47c54f565f1c061b8f38c7d Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Thu, 3 May 2012 12:57:58 +0000 Subject: [PATCH] added QSE_NWIO_KEEPALIVE and QSE_NWIO_REUSEADDR --- qse/include/qse/cmn/fio.h | 2 ++ qse/include/qse/cmn/nwio.h | 2 ++ qse/lib/awk/std.c | 2 +- qse/lib/cmn/Makefile.am | 2 +- qse/lib/cmn/Makefile.in | 10 +++++----- qse/lib/cmn/nwio.c | 21 +++++++++++++++++++++ 6 files changed, 32 insertions(+), 7 deletions(-) diff --git a/qse/include/qse/cmn/fio.h b/qse/include/qse/cmn/fio.h index 2ba7fc65..238d0cf6 100644 --- a/qse/include/qse/cmn/fio.h +++ b/qse/include/qse/cmn/fio.h @@ -127,6 +127,8 @@ enum qse_fio_mode_t typedef unsigned long qse_fio_hnd_t; #elif defined(__DOS__) typedef int qse_fio_hnd_t; +#elif defined(vms) || defined(__vms) + typedef void* qse_fio_hnd_t; /* struct FAB* */ #else typedef int qse_fio_hnd_t; #endif diff --git a/qse/include/qse/cmn/nwio.h b/qse/include/qse/cmn/nwio.h index a2eb4ddf..c296b526 100644 --- a/qse/include/qse/cmn/nwio.h +++ b/qse/include/qse/cmn/nwio.h @@ -41,6 +41,8 @@ enum qse_nwio_flag_t QSE_NWIO_TCP = (1 << 9), QSE_NWIO_UDP = (1 << 10), + QSE_NWIO_REUSEADDR = (1 << 12), + QSE_NWIO_KEEPALIVE = (1 << 13), /** do not reread if read has been interrupted */ QSE_NWIO_READNORETRY = (1 << 14), /** do not rewrite if write has been interrupted */ diff --git a/qse/lib/awk/std.c b/qse/lib/awk/std.c index b925a9c3..9585e1b3 100644 --- a/qse/lib/awk/std.c +++ b/qse/lib/awk/std.c @@ -806,7 +806,7 @@ static qse_ssize_t nwio_handler_open ( handle = qse_nwio_open ( qse_awk_rtx_getmmgr(rtx), 0, nwad, 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; diff --git a/qse/lib/cmn/Makefile.am b/qse/lib/cmn/Makefile.am index b7aefb0f..e51934bb 100644 --- a/qse/lib/cmn/Makefile.am +++ b/qse/lib/cmn/Makefile.am @@ -33,7 +33,6 @@ libqsecmn_la_SOURCES = \ env.c \ gdl.c \ htb.c \ - lda.c \ fio.c \ fma.c \ fmt.c \ @@ -42,6 +41,7 @@ libqsecmn_la_SOURCES = \ fs-move.c \ hton.c \ ipad.c \ + lda.c \ main.c \ mbwc.c \ mbwc-str.c \ diff --git a/qse/lib/cmn/Makefile.in b/qse/lib/cmn/Makefile.in index 41f9798d..621d5263 100644 --- a/qse/lib/cmn/Makefile.in +++ b/qse/lib/cmn/Makefile.in @@ -78,10 +78,10 @@ am__DEPENDENCIES_1 = libqsecmn_la_DEPENDENCIES = $(am__DEPENDENCIES_1) 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 \ - lda.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 \ - oht.lo opt.lo path-basename.lo path-canon.lo pio.lo pma.lo \ - rbt.lo rex.lo sio.lo sll.lo slmb.lo stdio.lo str-beg.lo \ + fio.lo fma.lo fmt.lo fs.lo fs-err.lo fs-move.lo hton.lo \ + ipad.lo lda.lo main.lo mbwc.lo mbwc-str.lo mem.lo nwad.lo \ + nwio.lo oht.lo opt.lo path-basename.lo path-canon.lo pio.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-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 \ @@ -309,7 +309,6 @@ libqsecmn_la_SOURCES = \ env.c \ gdl.c \ htb.c \ - lda.c \ fio.c \ fma.c \ fmt.c \ @@ -318,6 +317,7 @@ libqsecmn_la_SOURCES = \ fs-move.c \ hton.c \ ipad.c \ + lda.c \ main.c \ mbwc.c \ mbwc-str.c \ diff --git a/qse/lib/cmn/nwio.c b/qse/lib/cmn/nwio.c index 0d37967f..1a5f45c3 100644 --- a/qse/lib/cmn/nwio.c +++ b/qse/lib/cmn/nwio.c @@ -316,10 +316,17 @@ int qse_nwio_init ( 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) { qse_nwio_hnd_t handle; + if (flags & QSE_NWIO_REUSEADDR) { int optval = 1; setsockopt (nwio->handle, SOL_SOCKET, SO_REUSEADDR, (void*)&optval, QSE_SIZEOF(optval)); @@ -371,10 +378,17 @@ int qse_nwio_init ( 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) { qse_nwio_hnd_t handle; + if (flags & QSE_NWIO_REUSEADDR) { int optval = 1; setsockopt (nwio->handle, SOL_SOCKET, SO_REUSEADDR, (void*)&optval, QSE_SIZEOF(optval)); @@ -437,11 +451,18 @@ int qse_nwio_init ( } #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) { qse_nwio_hnd_t handle; #if defined(SO_REUSEADDR) + if (flags & QSE_NWIO_REUSEADDR) { int optval = 1; setsockopt (nwio->handle, SOL_SOCKET, SO_REUSEADDR, (void*)&optval, QSE_SIZEOF(optval));