namespace Msp {
namespace Net {
-/**
-Used by StreamListenSocket to construct a new socket from accept.
-*/
StreamSocket::StreamSocket(SocketHandle h, const SockAddr &paddr):
Socket(h, paddr),
connecting(false)
set_events(IO::P_INPUT);
}
-/**
-Constructs a new StreamSocket.
-*/
StreamSocket::StreamSocket(Family af, int proto):
Socket(af, SOCK_STREAM, proto),
connecting(false)
{ }
-/**
-Checks the status of an ongoing connection attempt. If the connection fails
-with an error, an exception is thrown.
-
-@return 0 if the connection finished, 1 if not
-*/
int StreamSocket::poll_connect(const Time::TimeDelta &timeout)
{
check_state(false);
return 1;
}
-/**
-Connects the socket to a remote address. In non-blocking mode, this function
-may return before the connection is finished. The caller must then use either
-the poll_connect function or an EventDispatcher to determine when the
-connection is finished.
-
-@return 0 if the connection finished, 1 if it is in progress
-*/
int StreamSocket::connect(const SockAddr &addr)
{
check_state(false);
void StreamSocket::on_event(IO::PollEvent ev)
{
- //cout<<"StreamSocket::on_event "<<ev<<'\n';
if((ev&(IO::P_OUTPUT|IO::P_ERROR)) && connecting)
{
int err;