8
8
* Guillermo Rodriguez Garcia <guille@iies.es>
9
9
* Purpose: GSocket main Unix and OS/2 file
10
10
* Licence: The wxWindows licence
11
* CVSID: $Id: gsocket.cpp 58386 2009-01-25 12:45:29Z VZ $
11
* CVSID: $Id: gsocket.cpp 66982 2011-02-20 11:04:45Z TIK $
12
12
* -------------------------------------------------------------------------
199
199
#if defined(HAVE_GETHOSTBYNAME)
200
200
static struct hostent * deepCopyHostent(struct hostent *h,
201
const struct hostent *he,
202
char *buffer, int size, int *err)
201
const struct hostent *he,
202
char *buffer, int size, int *err)
204
204
/* copy old structure */
205
205
memcpy(h, he, sizeof(struct hostent));
283
283
static wxMutex nameLock;
285
285
struct hostent * wxGethostbyname_r(const char *hostname, struct hostent *h,
286
void *buffer, int size, int *err)
286
void *buffer, int size, int *err)
289
289
struct hostent *he = NULL;
318
318
static wxMutex addrLock;
320
320
struct hostent * wxGethostbyaddr_r(const char *addr_buf, int buf_size,
321
int proto, struct hostent *h,
322
void *buffer, int size, int *err)
321
int proto, struct hostent *h,
322
void *buffer, int size, int *err)
324
324
struct hostent *he = NULL;
326
326
#if defined(HAVE_FUNC_GETHOSTBYNAME_R_6)
327
327
if (gethostbyaddr_r(addr_buf, buf_size, proto, h,
328
(char*)buffer, size, &he, err))
328
(char*)buffer, size, &he, err))
330
330
#elif defined(HAVE_FUNC_GETHOSTBYNAME_R_5)
331
331
he = gethostbyaddr_r(addr_buf, buf_size, proto, h, (char*)buffer, size, err);
332
332
#elif defined(HAVE_FUNC_GETHOSTBYNAME_R_3)
333
333
if (gethostbyaddr_r(addr_buf, buf_size, proto, h,
334
(struct hostent_data*) buffer))
334
(struct hostent_data*) buffer))
354
354
#if defined(HAVE_GETSERVBYNAME)
355
355
static struct servent * deepCopyServent(struct servent *s,
356
const struct servent *se,
357
char *buffer, int size)
356
const struct servent *se,
357
char *buffer, int size)
359
359
/* copy plain old structure */
360
360
memcpy(s, se, sizeof(struct servent));
418
418
static wxMutex servLock;
420
420
struct servent *wxGetservbyname_r(const char *port, const char *protocol,
421
struct servent *serv, void *buffer, int size)
421
struct servent *serv, void *buffer, int size)
423
423
struct servent *se = NULL;
424
424
#if defined(HAVE_FUNC_GETSERVBYNAME_R_6)
995
995
// If a local address has been set, then we need to bind to it before calling connect
996
996
if (m_local && m_local->m_addr)
998
bind(m_fd, m_local->m_addr, m_local->m_len);
998
if (bind(m_fd, m_local->m_addr, m_local->m_len) < 0)
1001
m_error = GSOCK_IOERR;
1001
1006
/* Connect it to the peer address, with a timeout (see below) */
1534
1539
GSocketError GSocket::Input_Timeout()
1542
// This seems to happen under OS X sometimes, see #8904.
1543
if ( m_fd == INVALID_SOCKET )
1545
m_error = GSOCK_TIMEDOUT;
1546
return GSOCK_TIMEDOUT;
1536
1550
struct timeval tv;
1537
1551
fd_set readfds;
2133
2147
struct servent serv;
2134
2148
se = wxGetservbyname_r(port, protocol, &serv,
2135
(void*)&buffer, sizeof(buffer));
2149
(void*)&buffer, sizeof(buffer));
2138
2152
/* the cast to int suppresses compiler warnings about subscript having the
2193
2207
he = wxGethostbyaddr_r(addr_buf, sizeof(addr->sin_addr), AF_INET, &temphost,
2194
(void*)&buffer, sizeof(buffer), &err);
2208
(void*)&buffer, sizeof(buffer), &err);
2195
2209
if (he == NULL)
2197
2211
address->m_error = GSOCK_NOHOST;