~ubuntu-branches/ubuntu/raring/wxwidgets2.8/raring

« back to all changes in this revision

Viewing changes to src/unix/gsocket.cpp

  • Committer: Package Import Robot
  • Author(s): Stéphane Graber
  • Date: 2012-01-07 13:59:25 UTC
  • mfrom: (1.1.9) (5.1.10 sid)
  • Revision ID: package-import@ubuntu.com-20120107135925-2601miy9ullcon9j
Tags: 2.8.12.1-6ubuntu1
* Resync from Debian, changes that were kept:
  - debian/rules: re-enable mediactrl. This allows libwx_gtk2u_media-2.8 to be
    built, as this is required by some applications (LP: #632984)
  - debian/control: Build-dep on libxt-dev for mediactrl.
  - Patches
    + fix-bashism-in-example
* Add conflict on python-wxgtk2.8 (<< 2.8.12.1-6ubuntu1~) to python-wxversion
  to guarantee upgrade ordering when moving from pycentral to dh_python2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 * -------------------------------------------------------------------------
13
13
 */
14
14
 
198
198
 
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)
203
203
{
204
204
  /* copy old structure */
205
205
  memcpy(h, he, sizeof(struct hostent));
283
283
static wxMutex nameLock;
284
284
#endif
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)
287
287
 
288
288
{
289
289
  struct hostent *he = NULL;
318
318
static wxMutex addrLock;
319
319
#endif
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)
323
323
{
324
324
  struct hostent *he = NULL;
325
325
  *err = 0;
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))
329
329
    he = NULL;
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))
335
335
  {
336
336
    he = NULL;
337
337
    *err = h_errno;
353
353
 
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)
358
358
{
359
359
  /* copy plain old structure */
360
360
  memcpy(s, se, sizeof(struct servent));
418
418
static wxMutex servLock;
419
419
#endif
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)
422
422
{
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)
997
997
  {
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)
 
999
    {
 
1000
      Close();
 
1001
      m_error = GSOCK_IOERR;
 
1002
      return GSOCK_IOERR;
 
1003
    }
999
1004
  }
1000
1005
 
1001
1006
  /* Connect it to the peer address, with a timeout (see below) */
1533
1538
 */
1534
1539
GSocketError GSocket::Input_Timeout()
1535
1540
{
 
1541
#ifdef __WXMAC__
 
1542
  // This seems to happen under OS X sometimes, see #8904.
 
1543
  if ( m_fd == INVALID_SOCKET )
 
1544
  {
 
1545
    m_error = GSOCK_TIMEDOUT;
 
1546
    return GSOCK_TIMEDOUT;
 
1547
  }
 
1548
#endif // __WXMAC__
 
1549
 
1536
1550
  struct timeval tv;
1537
1551
  fd_set readfds;
1538
1552
  int ret;
2132
2146
#endif
2133
2147
  struct servent serv;
2134
2148
  se = wxGetservbyname_r(port, protocol, &serv,
2135
 
                         (void*)&buffer, sizeof(buffer));
 
2149
                         (void*)&buffer, sizeof(buffer));
2136
2150
  if (!se)
2137
2151
  {
2138
2152
    /* the cast to int suppresses compiler warnings about subscript having the
2191
2205
#endif
2192
2206
  int err;
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)
2196
2210
  {
2197
2211
    address->m_error = GSOCK_NOHOST;