~ubuntu-branches/ubuntu/lucid/ktorrent/lucid

« back to all changes in this revision

Viewing changes to libbtcore/net/socket.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Thomas
  • Date: 2009-02-16 18:37:14 UTC
  • mfrom: (1.1.25 upstream) (0.4.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20090216183714-52tf47jrnmk4xkmp
Tags: 3.2+dfsg.1-2ubuntu1
* Merge with Debian, remaining changes: (LP: #296433)
  - Use Kubuntu's kde4.mk
  - Build-depend on libboost-serialization1.35-dev since unversioned -dev is
    in universe
  - Change plasma-applet-ktorrent to plasma-widget-ktorrent since we're
    supposed to call them widgets for the users

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
#include <util/log.h>
49
49
 
50
50
#ifdef Q_WS_WIN
51
 
#include <util/mingw.h>
 
51
#include <util/win32.h>
52
52
#define SHUT_RDWR SD_BOTH
53
53
#undef errno
54
54
#define errno WSAGetLastError()
108
108
                }
109
109
        }
110
110
        
 
111
        void Socket::reset()
 
112
        {
 
113
                close();
 
114
                int fd = socket(m_ip_version == 4 ? PF_INET : PF_INET6,SOCK_STREAM,0);
 
115
                if (fd < 0)
 
116
                        Out(SYS_GEN|LOG_IMPORTANT) << QString("Cannot create socket : %1").arg(strerror(errno)) << endl;
 
117
                m_fd = fd;
 
118
                
 
119
#if defined(Q_OS_MACX) || defined(Q_OS_DARWIN) || (defined(Q_OS_FREEBSD) && __FreeBSD_version < 600020 && !defined(__DragonFly__))
 
120
                int val = 1;
 
121
                if (setsockopt(m_fd,SOL_SOCKET,SO_NOSIGPIPE,&val,sizeof(int)) < 0)
 
122
                {
 
123
                        Out(SYS_CON|LOG_NOTICE) << QString("Failed to set the NOSIGPIPE option : %1").arg(strerror(errno)) << endl;
 
124
                }
 
125
#endif  
 
126
                m_state = IDLE;
 
127
        }
 
128
        
111
129
        void Socket::close()
112
130
        {
113
131
                if (m_fd >= 0)