[R-gregmisc-commits] r2141 - pkg/gtools/tests
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Aug 15 21:14:50 CEST 2016
Author: warnes
Date: 2016-08-15 21:14:49 +0200 (Mon, 15 Aug 2016)
New Revision: 2141
Added:
pkg/gtools/tests/test_setTCPNoDelay.R
Log:
Add test code for setTCPNoDelay
Added: pkg/gtools/tests/test_setTCPNoDelay.R
===================================================================
--- pkg/gtools/tests/test_setTCPNoDelay.R (rev 0)
+++ pkg/gtools/tests/test_setTCPNoDelay.R 2016-08-15 19:14:49 UTC (rev 2141)
@@ -0,0 +1,44 @@
+library('gtools')
+
+setTCPNoDelay <- function( socket, value=TRUE )
+{
+ if(!any(c("socket","sockconn") %in% class(socket)))
+ stop("socket must be a socket object")
+
+ buffer <- paste(rep(" ", 1000), sep='', collapse='')
+
+ if("sockconn" %in% class(socket))
+ conn <- getConnection(socket[1])
+ else
+ conn <- socket
+
+
+ retval <- .C("R_setTCPNoDelay",
+ socket=as.integer(socket[1]),
+ flag=as.integer(value),
+ status=integer(1),
+ status.str=as.character(buffer),
+ status.len=as.integer(nchar(buffer)),
+ package="gtools"
+ )
+
+ if(retval$status != 0)
+ stop( retval$status.str )
+ else
+ invisible(retval$status.str)
+}
+
+
+
+host <- "rdgas05026.am.boehringer.com"
+#host <- "www.r-project.org"
+socket <- make.socket(host, 80)
+print(socket)
+setTCPNoDelay(socket, TRUE)
+
+write.socket(socket, "GET /\n\n")
+while( (str <- read.socket(socket)) > "")
+ cat(str)
+close.socket(socket)
+
+read.socket(socket)
\ No newline at end of file
More information about the R-gregmisc-commits
mailing list