X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fnet%2Fstreamserversocket.cpp;h=9b583a141da552d420908826357528eb5b5b7cce;hb=32713c673d335f0d4667005a9e6f658e8a616e8f;hp=1823dbd488ccf9585e020a11ef94d8bb2f092606;hpb=b069cfc670fb78b4b429d07d2aadb59628426a25;p=libs%2Fnet.git diff --git a/source/net/streamserversocket.cpp b/source/net/streamserversocket.cpp index 1823dbd..9b583a1 100644 --- a/source/net/streamserversocket.cpp +++ b/source/net/streamserversocket.cpp @@ -20,6 +20,9 @@ StreamServerSocket::StreamServerSocket(Family af, int proto): void StreamServerSocket::listen(const SockAddr &addr, unsigned backlog) { + if(listening) + throw bad_socket_state("already listening"); + bind(addr); int err = ::listen(priv->handle, backlog); @@ -38,7 +41,7 @@ StreamSocket *StreamServerSocket::accept() SockAddr::SysAddr sa; Private new_p; - new_p.handle = check_sys_error(::accept(priv->handle, reinterpret_cast(&sa.addr), &sa.size)); + new_p.handle = check_sys_error(::accept(priv->handle, reinterpret_cast(&sa.addr), &sa.size), "accept"); RefPtr paddr = SockAddr::new_from_sys(sa); return new StreamSocket(new_p, *paddr);