The R Project SVN R

Rev

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

Rev 75220 Rev 76978
Line 1... Line 1...
1
/*
1
/*
2
 *  R : A Computer Language for Statistical Data Analysis
2
 *  R : A Computer Language for Statistical Data Analysis
3
 
3
 
4
 *  Copyright (C) 1998-2017   The R Core Team
4
 *  Copyright (C) 1998-2019   The R Core Team
5
 *  Copyright (C) 1996, 1997  Robert Gentleman and Ross Ihaka
5
 *  Copyright (C) 1996, 1997  Robert Gentleman and Ross Ihaka
6
 *
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
8
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; either version 2 of the License, or
9
 *  the Free Software Foundation; either version 2 of the License, or
Line 176... Line 176...
176
#endif
176
#endif
177
#ifdef HAVE_SYS_SELECT_H
177
#ifdef HAVE_SYS_SELECT_H
178
#include <sys/select.h>
178
#include <sys/select.h>
179
#endif
179
#endif
180
 
180
 
-
 
181
struct hostent *R_gethostbyname(const char *name);
181
 
182
 
182
#ifndef Win32
183
#ifndef Win32
183
#define closesocket(s) close(s)
184
#define closesocket(s) close(s)
184
#define SOCKET int
185
#define SOCKET int
185
#endif
186
#endif
Line 421... Line 422...
421
    if (status < 0) {
422
    if (status < 0) {
422
	CLOSE_N_RETURN(-1);
423
	CLOSE_N_RETURN(-1);
423
    }
424
    }
424
#endif
425
#endif
425
 
426
 
426
    if (! (hp = gethostbyname(host))) CLOSE_N_RETURN(-1);
427
    if (! (hp = R_gethostbyname(host))) CLOSE_N_RETURN(-1);
427
 
428
 
428
    memcpy((char *)&server.sin_addr, hp->h_addr_list[0], hp->h_length);
429
    memcpy((char *)&server.sin_addr, hp->h_addr_list[0], hp->h_length);
429
    server.sin_port = htons((short)port);
430
    server.sin_port = htons((short)port);
430
    server.sin_family = AF_INET;
431
    server.sin_family = AF_INET;
431
 
432
 
Line 565... Line 566...
565
	}
566
	}
566
    } while (/* ! blocking && */len > 0);
567
    } while (/* ! blocking && */len > 0);
567
    return out;
568
    return out;
568
}
569
}
569
 
570
 
-
 
571
struct hostent *R_gethostbyname(const char *name)
-
 
572
{
-
 
573
    struct hostent *ans = gethostbyname(name);
-
 
574
 
-
 
575
    /* hard-code IPv4 address for localhost to be robust against
-
 
576
       misconfigured systems */
-
 
577
 
-
 
578
    if (ans == NULL && !strcmp(name, "localhost"))
-
 
579
	ans = gethostbyname("127.0.0.1");
-
 
580
    return ans;
-
 
581
}
-
 
582