The R Project SVN R

Rev

Rev 26366 | Rev 32492 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 26366 Rev 26370
Line 31... Line 31...
31
 
31
 
32
#include <Defn.h>
32
#include <Defn.h>
33
#include <Rconnections.h>
33
#include <Rconnections.h>
34
#include <R_ext/R-ftp-http.h>
34
#include <R_ext/R-ftp-http.h>
35
 
35
 
-
 
36
static void listencleanup(void *data)
-
 
37
{
-
 
38
    int *psock = data;
-
 
39
    R_SockClose(*psock);
-
 
40
}
-
 
41
 
36
static Rboolean sock_open(Rconnection con)
42
static Rboolean sock_open(Rconnection con)
37
{
43
{
38
    Rsockconn this = (Rsockconn)con->private;
44
    Rsockconn this = (Rsockconn)con->private;
39
    int sock, sock1, mlen;
45
    int sock, sock1, mlen;
40
    int timeout = asInteger(GetOption(install("timeout"), R_NilValue));
46
    int timeout = asInteger(GetOption(install("timeout"), R_NilValue));
Line 48... Line 54...
48
	sock1 = R_SockOpen(this->port);
54
	sock1 = R_SockOpen(this->port);
49
	if(sock1 < 0) {
55
	if(sock1 < 0) {
50
	    warning("port %d cannot be opened", this->port);
56
	    warning("port %d cannot be opened", this->port);
51
	    return FALSE;
57
	    return FALSE;
52
	}
58
	}
-
 
59
	{
-
 
60
	    RCNTXT cntxt;
-
 
61
 
-
 
62
	    /* set up a context which will close socket on jump. */
-
 
63
	    begincontext(&cntxt, CTXT_CCODE, R_NilValue, R_NilValue,
-
 
64
			 R_NilValue, R_NilValue, R_NilValue);
-
 
65
	    cntxt.cend = &listencleanup;
-
 
66
	    cntxt.cenddata = &sock1;
53
	sock = R_SockListen(sock1, buf, 256);
67
	    sock = R_SockListen(sock1, buf, 256);
-
 
68
	    endcontext(&cntxt);
-
 
69
	}
54
	if(sock < 0) {
70
	if(sock < 0) {
55
	    warning("problem in listening on this socket");
71
	    warning("problem in listening on this socket");
56
	    R_SockClose(sock1);
72
	    R_SockClose(sock1);
57
	    return FALSE;
73
	    return FALSE;
58
	}
74
	}