- Add wxDateTime::DiffAsDateSpan() and wxDateSpan::GetTotalMonths() (jonasr).
- Add wxVector::assign() (Jonas Rydberg).
- Add wx[F]File{Input,Output}Stream::GetFile() (troelsk).
+- Add wxSocketBase::GetSocket() (Laurent Poujoulat).
- Add Nepali translation (Him Prasad Gautam).
All (GUI):
// define some symbols which winsock.h defines but traditional BSD headers
// don't
-#ifndef __WINDOWS__
- #define SOCKET int
-#endif
-
#ifndef INVALID_SOCKET
#define INVALID_SOCKET (-1)
#endif
// TODO: make these fields protected and provide accessors for those of
// them that wxSocketBase really needs
//protected:
- SOCKET m_fd;
+ wxSOCKET_T m_fd;
int m_initialRecvBufferSize;
int m_initialSendBufferSize;
// Types and constants
// ------------------------------------------------------------------------
+// Define the type of native sockets.
+#if defined(__WINDOWS__)
+ // Although socket descriptors are still 32 bit values, even under Win64,
+ // the socket type is 64 bit there.
+ typedef wxUIntPtr wxSOCKET_T;
+#else
+ typedef int wxSOCKET_T;
+#endif
+
+
// Types of different socket notifications or events.
//
// NB: the values here should be consecutive and start with 0 as they are
void SetNotify(wxSocketEventFlags flags);
void Notify(bool notify);
+ // Get the underlying socket descriptor.
+ wxSOCKET_T GetSocket() const;
+
// initialize/shutdown the sockets (done automatically so there is no need
// to call these functions usually)
//
/////////////////////////////////////////////////////////////////////////////
+/**
+ The type of the native socket.
+
+ Notice that the definition below is simplified and this type is not always
+ int, e.g. it is a 64 bit integer type under Win64.
+
+ @since 2.9.5
+ */
+typedef int wxSOCKET_T;
+
/**
@class wxIPaddress
*/
void SetNotify(wxSocketEventFlags flags);
+ /**
+ Returns the native socket descriptor.
+
+ This is intended to use with rarely used specific platform features
+ that can only be accessed via the actual socket descriptor.
+
+ Do not use this for reading or writing data from or to the socket as
+ this would almost surely interfere with wxSocket code logic and result
+ in unexpected behaviour.
+
+ The socket must be successfully initialized, e.g. connected for client
+ sockets, before this method can be called.
+
+ @return Returns the native socket descriptor.
+
+ @since 2.9.5
+ */
+ wxSOCKET_T GetSocket() const;
+
//@}
};
{
wxSockAddressStorage from;
WX_SOCKLEN_T fromlen = sizeof(from);
- const SOCKET fd = accept(m_fd, &from.addr, &fromlen);
+ const wxSOCKET_T fd = accept(m_fd, &from.addr, &fromlen);
// accepting is similar to reading in the sense that it resets "ready for
// read" flag on the socket
return;
}
- // Notice that we need a cast as SOCKET is 64 bit under Win64 and that the
- // cast is safe because a SOCKET is a handle and so limited to 32 (or,
- // actually, even 24) bit values anyhow.
+ // Notice that we need a cast as wxSOCKET_T is 64 bit under Win64 and that
+ // the cast is safe because a wxSOCKET_T is a handle and so limited to 32
+ // (or, actually, even 24) bit values anyhow.
wxLogTrace( wxTRACE_Socket, wxT("wxSocketServer on fd %u"),
static_cast<unsigned>(m_impl->m_fd) );
}
return DoWait(seconds, milliseconds, wxSOCKET_CONNECTION_FLAG) == 1;
}
+wxSOCKET_T wxSocketBase::GetSocket() const
+{
+ wxASSERT_MSG( m_impl, wxS("Socket not initialised") );
+
+ return m_impl->m_fd;
+}
+
+
bool wxSocketBase::GetOption(int level, int optname, void *optval, int *optlen)
{
wxASSERT_MSG( m_impl, wxT("Socket not initialised") );