mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-23 08:31:43 +02:00
socket initialization and other fixes
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// DatagramSocketImpl.h
|
// DatagramSocketImpl.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/svn/Net/include/Poco/Net/DatagramSocketImpl.h#2 $
|
// $Id: //poco/Main/Net/include/Poco/Net/DatagramSocketImpl.h#3 $
|
||||||
//
|
//
|
||||||
// Library: Net
|
// Library: Net
|
||||||
// Package: Sockets
|
// Package: Sockets
|
||||||
@@ -59,7 +59,7 @@ public:
|
|||||||
/// be an IPv6 socket. Otherwise, it will be
|
/// be an IPv6 socket. Otherwise, it will be
|
||||||
/// an IPv4 socket.
|
/// an IPv4 socket.
|
||||||
|
|
||||||
DatagramSocketImpl(IPAddress::Family family);
|
explicit DatagramSocketImpl(IPAddress::Family family);
|
||||||
/// Creates an unconnected datagram socket.
|
/// Creates an unconnected datagram socket.
|
||||||
///
|
///
|
||||||
/// The socket will be created for the
|
/// The socket will be created for the
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// HTTPServerSession.h
|
// HTTPServerSession.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/svn/Net/include/Poco/Net/HTTPServerSession.h#2 $
|
// $Id: //poco/Main/Net/include/Poco/Net/HTTPServerSession.h#5 $
|
||||||
//
|
//
|
||||||
// Library: Net
|
// Library: Net
|
||||||
// Package: HTTPServer
|
// Package: HTTPServer
|
||||||
@@ -43,6 +43,8 @@
|
|||||||
#include "Poco/Net/Net.h"
|
#include "Poco/Net/Net.h"
|
||||||
#include "Poco/Net/HTTPSession.h"
|
#include "Poco/Net/HTTPSession.h"
|
||||||
#include "Poco/Net/SocketAddress.h"
|
#include "Poco/Net/SocketAddress.h"
|
||||||
|
#include "Poco/Net/HTTPServerSession.h"
|
||||||
|
#include "Poco/Net/HTTPServerParams.h"
|
||||||
#include "Poco/Timespan.h"
|
#include "Poco/Timespan.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -50,16 +52,13 @@ namespace Poco {
|
|||||||
namespace Net {
|
namespace Net {
|
||||||
|
|
||||||
|
|
||||||
class HTTPServerParams;
|
|
||||||
|
|
||||||
|
|
||||||
class Net_API HTTPServerSession: public HTTPSession
|
class Net_API HTTPServerSession: public HTTPSession
|
||||||
/// This class handles the server side of a
|
/// This class handles the server side of a
|
||||||
/// HTTP session. It is used internally by
|
/// HTTP session. It is used internally by
|
||||||
/// HTTPServer.
|
/// HTTPServer.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HTTPServerSession(const StreamSocket& socket, HTTPServerParams* pParams);
|
HTTPServerSession(const StreamSocket& socket, HTTPServerParams::Ptr pParams);
|
||||||
/// Creates the HTTPServerSession.
|
/// Creates the HTTPServerSession.
|
||||||
|
|
||||||
virtual ~HTTPServerSession();
|
virtual ~HTTPServerSession();
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// SocketAddress.h
|
// SocketAddress.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/svn/Net/include/Poco/Net/SocketAddress.h#2 $
|
// $Id: //poco/Main/Net/include/Poco/Net/SocketAddress.h#3 $
|
||||||
//
|
//
|
||||||
// Library: Net
|
// Library: Net
|
||||||
// Package: NetCore
|
// Package: NetCore
|
||||||
@@ -126,6 +126,9 @@ public:
|
|||||||
std::string toString() const;
|
std::string toString() const;
|
||||||
/// Returns a string representation of the address.
|
/// Returns a string representation of the address.
|
||||||
|
|
||||||
|
IPAddress::Family family() const;
|
||||||
|
/// Returns the address family of the host's address.
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
MAX_ADDRESS_LENGTH =
|
MAX_ADDRESS_LENGTH =
|
||||||
@@ -156,6 +159,12 @@ inline void swap(SocketAddress& a1, SocketAddress& a2)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline IPAddress::Family SocketAddress::family() const
|
||||||
|
{
|
||||||
|
return host().family();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::Net
|
} } // namespace Poco::Net
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// StreamSocket.h
|
// StreamSocket.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Net/include/Poco/Net/StreamSocket.h#3 $
|
// $Id: //poco/Main/Net/include/Poco/Net/StreamSocket.h#4 $
|
||||||
//
|
//
|
||||||
// Library: Net
|
// Library: Net
|
||||||
// Package: Sockets
|
// Package: Sockets
|
||||||
@@ -66,6 +66,15 @@ public:
|
|||||||
/// Creates a stream socket and connects it to
|
/// Creates a stream socket and connects it to
|
||||||
/// the socket specified by address.
|
/// the socket specified by address.
|
||||||
|
|
||||||
|
explicit StreamSocket(IPAddress::Family family);
|
||||||
|
/// Creates an unconnected stream socket
|
||||||
|
/// for the given address family.
|
||||||
|
///
|
||||||
|
/// This is useful if certain socket options
|
||||||
|
/// (like send and receive buffer) sizes, that must
|
||||||
|
/// be set before connecting the socket, will be
|
||||||
|
/// set later on.
|
||||||
|
|
||||||
StreamSocket(const Socket& socket);
|
StreamSocket(const Socket& socket);
|
||||||
/// Creates the StreamSocket with the SocketImpl
|
/// Creates the StreamSocket with the SocketImpl
|
||||||
/// from another socket. The SocketImpl must be
|
/// from another socket. The SocketImpl must be
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// StreamSocketImpl.h
|
// StreamSocketImpl.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/svn/Net/include/Poco/Net/StreamSocketImpl.h#2 $
|
// $Id: //poco/Main/Net/include/Poco/Net/StreamSocketImpl.h#3 $
|
||||||
//
|
//
|
||||||
// Library: Net
|
// Library: Net
|
||||||
// Package: Sockets
|
// Package: Sockets
|
||||||
@@ -54,6 +54,10 @@ class Net_API StreamSocketImpl: public SocketImpl
|
|||||||
public:
|
public:
|
||||||
StreamSocketImpl();
|
StreamSocketImpl();
|
||||||
/// Creates a StreamSocketImpl.
|
/// Creates a StreamSocketImpl.
|
||||||
|
|
||||||
|
explicit StreamSocketImpl(IPAddress::Family addressFamily);
|
||||||
|
/// Creates a SocketImpl, with the underlying
|
||||||
|
/// socket initialized for the given address family.
|
||||||
|
|
||||||
StreamSocketImpl(poco_socket_t sockfd);
|
StreamSocketImpl(poco_socket_t sockfd);
|
||||||
/// Creates a StreamSocketImpl using the given native socket.
|
/// Creates a StreamSocketImpl using the given native socket.
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// DatagramSocketImpl.cpp
|
// DatagramSocketImpl.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/svn/Net/src/DatagramSocketImpl.cpp#2 $
|
// $Id: //poco/Main/Net/src/DatagramSocketImpl.cpp#7 $
|
||||||
//
|
//
|
||||||
// Library: Net
|
// Library: Net
|
||||||
// Package: Sockets
|
// Package: Sockets
|
||||||
@@ -60,7 +60,6 @@ DatagramSocketImpl::DatagramSocketImpl(IPAddress::Family family)
|
|||||||
init(AF_INET6);
|
init(AF_INET6);
|
||||||
#endif
|
#endif
|
||||||
else throw InvalidArgumentException("Invalid or unsupported address family passed to DatagramSocketImpl");
|
else throw InvalidArgumentException("Invalid or unsupported address family passed to DatagramSocketImpl");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// HTTPClientSession.cpp
|
// HTTPClientSession.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Net/src/HTTPClientSession.cpp#21 $
|
// $Id: //poco/Main/Net/src/HTTPClientSession.cpp#22 $
|
||||||
//
|
//
|
||||||
// Library: Net
|
// Library: Net
|
||||||
// Package: HTTPClient
|
// Package: HTTPClient
|
||||||
@@ -175,7 +175,7 @@ std::ostream& HTTPClientSession::sendRequest(HTTPRequest& request)
|
|||||||
_pResponseStream = 0;
|
_pResponseStream = 0;
|
||||||
|
|
||||||
bool keepAlive = getKeepAlive();
|
bool keepAlive = getKeepAlive();
|
||||||
if (connected() && !keepAlive || mustReconnect())
|
if ((connected() && !keepAlive) || mustReconnect())
|
||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
_mustReconnect = false;
|
_mustReconnect = false;
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// HTTPServerSession.cpp
|
// HTTPServerSession.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Net/src/HTTPServerSession.cpp#9 $
|
// $Id: //poco/Main/Net/src/HTTPServerSession.cpp#11 $
|
||||||
//
|
//
|
||||||
// Library: Net
|
// Library: Net
|
||||||
// Package: HTTPServer
|
// Package: HTTPServer
|
||||||
@@ -35,14 +35,13 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "Poco/Net/HTTPServerSession.h"
|
#include "Poco/Net/HTTPServerSession.h"
|
||||||
#include "Poco/Net/HTTPServerParams.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Net {
|
namespace Net {
|
||||||
|
|
||||||
|
|
||||||
HTTPServerSession::HTTPServerSession(const StreamSocket& socket, HTTPServerParams* pParams):
|
HTTPServerSession::HTTPServerSession(const StreamSocket& socket, HTTPServerParams::Ptr pParams):
|
||||||
HTTPSession(socket, pParams->getKeepAlive()),
|
HTTPSession(socket, pParams->getKeepAlive()),
|
||||||
_firstRequest(true),
|
_firstRequest(true),
|
||||||
_keepAliveTimeout(pParams->getKeepAliveTimeout()),
|
_keepAliveTimeout(pParams->getKeepAliveTimeout()),
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// HostEntry.cpp
|
// HostEntry.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Net/src/HostEntry.cpp#8 $
|
// $Id: //poco/Main/Net/src/HostEntry.cpp#9 $
|
||||||
//
|
//
|
||||||
// Library: Net
|
// Library: Net
|
||||||
// Package: NetCore
|
// Package: NetCore
|
||||||
@@ -89,9 +89,21 @@ HostEntryImpl::HostEntryImpl(struct addrinfo* ainfo)
|
|||||||
for (struct addrinfo* ai = ainfo; ai; ai = ai->ai_next)
|
for (struct addrinfo* ai = ainfo; ai; ai = ai->ai_next)
|
||||||
{
|
{
|
||||||
if (ai->ai_canonname)
|
if (ai->ai_canonname)
|
||||||
|
{
|
||||||
_name.assign(ai->ai_canonname);
|
_name.assign(ai->ai_canonname);
|
||||||
|
}
|
||||||
else if (ai->ai_addrlen && ai->ai_addr)
|
else if (ai->ai_addrlen && ai->ai_addr)
|
||||||
_addresses.push_back(IPAddress(ai->ai_addr, (poco_socklen_t) ai->ai_addrlen));
|
{
|
||||||
|
switch (ai->ai_addr->sa_family)
|
||||||
|
{
|
||||||
|
case AF_INET:
|
||||||
|
_addresses.push_back(IPAddress(&reinterpret_cast<struct sockaddr_in*>(&ai->ai_addr)->sin_addr, sizeof(in_addr)));
|
||||||
|
break;
|
||||||
|
case AF_INET6:
|
||||||
|
_addresses.push_back(IPAddress(&reinterpret_cast<struct sockaddr_in6*>(&ai->ai_addr)->sin6_addr, sizeof(in6_addr)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// ICMPPacket.cpp
|
// ICMPPacket.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/svn/Net/src/ICMPPacket.cpp#2 $
|
// $Id: //poco/Main/Net/src/ICMPPacket.cpp#5 $
|
||||||
//
|
//
|
||||||
// Library: Net
|
// Library: Net
|
||||||
// Package: ICMP
|
// Package: ICMP
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// MultipartReader.cpp
|
// MultipartReader.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/svn/Net/src/MultipartReader.cpp#2 $
|
// $Id: //poco/Main/Net/src/MultipartReader.cpp#13 $
|
||||||
//
|
//
|
||||||
// Library: Net
|
// Library: Net
|
||||||
// Package: Messages
|
// Package: Messages
|
||||||
@@ -76,7 +76,7 @@ int MultipartStreamBuf::readFromDevice(char* buffer, std::streamsize length)
|
|||||||
int ch = _istr.get();
|
int ch = _istr.get();
|
||||||
if (ch == eof) return -1;
|
if (ch == eof) return -1;
|
||||||
*buffer++ = (char) ch; ++n;
|
*buffer++ = (char) ch; ++n;
|
||||||
if (ch == '\n' || ch == '\r' && _istr.peek() == '\n')
|
if (ch == '\n' || (ch == '\r' && _istr.peek() == '\n'))
|
||||||
{
|
{
|
||||||
if (ch == '\r')
|
if (ch == '\r')
|
||||||
{
|
{
|
||||||
@@ -102,7 +102,7 @@ int MultipartStreamBuf::readFromDevice(char* buffer, std::streamsize length)
|
|||||||
}
|
}
|
||||||
if (it == end)
|
if (it == end)
|
||||||
{
|
{
|
||||||
if (ch == '\n' || ch == '\r' && _istr.peek() == '\n')
|
if (ch == '\n' || (ch == '\r' && _istr.peek() == '\n'))
|
||||||
{
|
{
|
||||||
if (ch == '\r')
|
if (ch == '\r')
|
||||||
{
|
{
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// QuotedPrintableEncoder.cpp
|
// QuotedPrintableEncoder.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/svn/Net/src/QuotedPrintableEncoder.cpp#2 $
|
// $Id: //poco/Main/Net/src/QuotedPrintableEncoder.cpp#7 $
|
||||||
//
|
//
|
||||||
// Library: Net
|
// Library: Net
|
||||||
// Package: Messages
|
// Package: Messages
|
||||||
@@ -83,7 +83,7 @@ int QuotedPrintableEncoderBuf::writeToDevice(char c)
|
|||||||
_pending = charToInt(c);
|
_pending = charToInt(c);
|
||||||
return _pending;
|
return _pending;
|
||||||
}
|
}
|
||||||
else if (c == '\r' || c == '\n' || c > 32 && c < 127 && c != '=')
|
else if (c == '\r' || c == '\n' || (c > 32 && c < 127 && c != '='))
|
||||||
{
|
{
|
||||||
writeRaw(c);
|
writeRaw(c);
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// RawSocketImpl.cpp
|
// RawSocketImpl.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/svn/Net/src/RawSocketImpl.cpp#2 $
|
// $Id: //poco/Main/Net/src/RawSocketImpl.cpp#10 $
|
||||||
//
|
//
|
||||||
// Library: Net
|
// Library: Net
|
||||||
// Package: Sockets
|
// Package: Sockets
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// SocketImpl.cpp
|
// SocketImpl.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Net/src/SocketImpl.cpp#26 $
|
// $Id: //poco/Main/Net/src/SocketImpl.cpp#28 $
|
||||||
//
|
//
|
||||||
// Library: Net
|
// Library: Net
|
||||||
// Package: Sockets
|
// Package: Sockets
|
||||||
@@ -41,12 +41,12 @@
|
|||||||
#include "Poco/Timestamp.h"
|
#include "Poco/Timestamp.h"
|
||||||
#include <string.h> // FD_SET needs memset on some platforms, so we can't use <cstring>
|
#include <string.h> // FD_SET needs memset on some platforms, so we can't use <cstring>
|
||||||
#if defined(POCO_HAVE_FD_POLL)
|
#if defined(POCO_HAVE_FD_POLL)
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
#endif
|
#endif
|
||||||
#if defined(sun) || defined(__sun) || defined(__sun__)
|
#if defined(sun) || defined(__sun) || defined(__sun__)
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stropts.h>
|
#include <stropts.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using Poco::IOException;
|
using Poco::IOException;
|
||||||
using Poco::TimeoutException;
|
using Poco::TimeoutException;
|
||||||
@@ -120,9 +120,10 @@ void SocketImpl::connect(const SocketAddress& address)
|
|||||||
|
|
||||||
void SocketImpl::connect(const SocketAddress& address, const Poco::Timespan& timeout)
|
void SocketImpl::connect(const SocketAddress& address, const Poco::Timespan& timeout)
|
||||||
{
|
{
|
||||||
poco_assert (_sockfd == POCO_INVALID_SOCKET);
|
if (_sockfd == POCO_INVALID_SOCKET)
|
||||||
|
{
|
||||||
init(address.af());
|
init(address.af());
|
||||||
|
}
|
||||||
setBlocking(false);
|
setBlocking(false);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -330,7 +331,7 @@ int SocketImpl::receiveFrom(void* buffer, int length, SocketAddress& address, in
|
|||||||
void SocketImpl::sendUrgent(unsigned char data)
|
void SocketImpl::sendUrgent(unsigned char data)
|
||||||
{
|
{
|
||||||
poco_assert (_sockfd != POCO_INVALID_SOCKET);
|
poco_assert (_sockfd != POCO_INVALID_SOCKET);
|
||||||
|
|
||||||
int rc = ::send(_sockfd, reinterpret_cast<const char*>(&data), sizeof(data), MSG_OOB);
|
int rc = ::send(_sockfd, reinterpret_cast<const char*>(&data), sizeof(data), MSG_OOB);
|
||||||
if (rc < 0) error();
|
if (rc < 0) error();
|
||||||
}
|
}
|
||||||
@@ -346,24 +347,21 @@ int SocketImpl::available()
|
|||||||
|
|
||||||
bool SocketImpl::poll(const Poco::Timespan& timeout, int mode)
|
bool SocketImpl::poll(const Poco::Timespan& timeout, int mode)
|
||||||
{
|
{
|
||||||
poco_assert (_sockfd != POCO_INVALID_SOCKET);
|
|
||||||
|
|
||||||
#if defined(POCO_HAVE_FD_POLL)
|
#if defined(POCO_HAVE_FD_POLL)
|
||||||
|
|
||||||
pollfd pollBuf;
|
pollfd pollBuf;
|
||||||
|
|
||||||
memset(&pollBuf, 0, sizeof(pollfd));
|
memset(&pollBuf, 0, sizeof(pollfd));
|
||||||
pollBuf.fd = _sockfd;
|
pollBuf.fd = _sockfd;
|
||||||
if (mode & SELECT_READ) pollBuf.events |= POLLIN;
|
if (mode & SELECT_READ) pollBuf.events |= POLLIN;
|
||||||
if (mode & SELECT_WRITE) pollBuf.events |= POLLOUT;
|
if (mode & SELECT_WRITE) pollBuf.events |= POLLOUT;
|
||||||
|
|
||||||
Poco::Timespan remainingTime(timeout);
|
Poco::Timespan remainingTime(timeout);
|
||||||
int rc;
|
int rc;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
Poco::Timestamp start;
|
Poco::Timestamp start;
|
||||||
rc = ::poll(&pollBuf, 1, remainingTime.totalMilliseconds());
|
rc = ::poll(&pollBuf, 1, remainingTime.totalMilliseconds());
|
||||||
|
|
||||||
if (rc < 0 && lastError() == POCO_EINTR)
|
if (rc < 0 && lastError() == POCO_EINTR)
|
||||||
{
|
{
|
||||||
Poco::Timestamp end;
|
Poco::Timestamp end;
|
||||||
@@ -373,10 +371,9 @@ bool SocketImpl::poll(const Poco::Timespan& timeout, int mode)
|
|||||||
else
|
else
|
||||||
remainingTime = 0;
|
remainingTime = 0;
|
||||||
}
|
}
|
||||||
} while (rc < 0 && lastError() == POCO_EINTR);
|
}
|
||||||
|
while (rc < 0 && lastError() == POCO_EINTR);
|
||||||
#else
|
#else
|
||||||
|
|
||||||
fd_set fdRead;
|
fd_set fdRead;
|
||||||
fd_set fdWrite;
|
fd_set fdWrite;
|
||||||
fd_set fdExcept;
|
fd_set fdExcept;
|
||||||
@@ -415,9 +412,7 @@ bool SocketImpl::poll(const Poco::Timespan& timeout, int mode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (rc < 0 && lastError() == POCO_EINTR);
|
while (rc < 0 && lastError() == POCO_EINTR);
|
||||||
|
#endif // POCO_HAVE_FD_POLL
|
||||||
#endif
|
|
||||||
|
|
||||||
if (rc < 0) error();
|
if (rc < 0) error();
|
||||||
return rc > 0;
|
return rc > 0;
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// StreamSocket.cpp
|
// StreamSocket.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Net/src/StreamSocket.cpp#9 $
|
// $Id: //poco/Main/Net/src/StreamSocket.cpp#10 $
|
||||||
//
|
//
|
||||||
// Library: Net
|
// Library: Net
|
||||||
// Package: Sockets
|
// Package: Sockets
|
||||||
@@ -57,6 +57,11 @@ StreamSocket::StreamSocket(const SocketAddress& address): Socket(new StreamSocke
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
StreamSocket::StreamSocket(IPAddress::Family family): Socket(new StreamSocketImpl(family))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
StreamSocket::StreamSocket(const Socket& socket): Socket(socket)
|
StreamSocket::StreamSocket(const Socket& socket): Socket(socket)
|
||||||
{
|
{
|
||||||
if (!dynamic_cast<StreamSocketImpl*>(impl()))
|
if (!dynamic_cast<StreamSocketImpl*>(impl()))
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// StreamSocketImpl.cpp
|
// StreamSocketImpl.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Net/src/StreamSocketImpl.cpp#8 $
|
// $Id: //poco/Main/Net/src/StreamSocketImpl.cpp#9 $
|
||||||
//
|
//
|
||||||
// Library: Net
|
// Library: Net
|
||||||
// Package: Sockets
|
// Package: Sockets
|
||||||
@@ -46,6 +46,18 @@ StreamSocketImpl::StreamSocketImpl()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
StreamSocketImpl::StreamSocketImpl(IPAddress::Family family)
|
||||||
|
{
|
||||||
|
if (family == IPAddress::IPv4)
|
||||||
|
init(AF_INET);
|
||||||
|
#if defined(POCO_HAVE_IPv6)
|
||||||
|
else if (family == IPAddress::IPv6)
|
||||||
|
init(AF_INET6);
|
||||||
|
#endif
|
||||||
|
else throw InvalidArgumentException("Invalid or unsupported address family passed to StreamSocketImpl");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
StreamSocketImpl::StreamSocketImpl(poco_socket_t sockfd): SocketImpl(sockfd)
|
StreamSocketImpl::StreamSocketImpl(poco_socket_t sockfd): SocketImpl(sockfd)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
//
|
//
|
||||||
// TCPServerDispatcher.cpp
|
// TCPServerDispatcher.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Net/src/TCPServerDispatcher.cpp#10 $
|
// $Id: //poco/Main/Net/src/TCPServerDispatcher.cpp#11 $
|
||||||
//
|
//
|
||||||
// Library: Net
|
// Library: Net
|
||||||
// Package: TCPServer
|
// Package: TCPServer
|
||||||
@@ -139,7 +139,7 @@ void TCPServerDispatcher::run()
|
|||||||
}
|
}
|
||||||
|
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
if (_stopped || _currentThreads > 1 && _queue.empty())
|
if (_stopped || (_currentThreads > 1 && _queue.empty()))
|
||||||
{
|
{
|
||||||
--_currentThreads;
|
--_currentThreads;
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user