]> git.tdb.fi Git - libs/net.git/blobdiff - source/streamsocket.h
Add an overload for resolve that takes host and service separately
[libs/net.git] / source / streamsocket.h
index 0bba5c39c1be7adff4d06cc85802368871b7610a..8b39e91afd358214168c977e299e01bc714d3e76 100644 (file)
@@ -1,36 +1,33 @@
-/* $Id$
-
-This file is part of libmspnet
-Copyright © 2008  Mikkosoft Productions, Mikko Rasa
-Distributed under the LGPL
-*/
-
 #ifndef MSP_NET_STREAMSOCKET_H_
 #define MSP_NET_STREAMSOCKET_H_
 
-#include "socket.h"
+#include "clientsocket.h"
 
 namespace Msp {
 namespace Net {
 
-class StreamSocket: public Socket
+class StreamSocket: public ClientSocket
 {
-       friend class StreamListenSocket;
-public:
-       /**
-       Emitted when the socket finishes connecting.  The argument is a standard
-       error code, 0 indicating success.
-       */
-       sigc::signal<void, int> signal_connect_finished;
-
-       StreamSocket(Family, int =0);
-       bool get_connecting() const { return connecting; }
-       int poll_connect(const Time::TimeDelta &);
-       int connect(const SockAddr &);
+       friend class StreamServerSocket;
+
 private:
-       bool connecting;
+       /// Used by StreamListenSocket to construct a new socket from accept.
+       StreamSocket(const Private &, const SockAddr &);
+public:
+       StreamSocket(Family, int = 0);
+
+       /** Connects to a remote address.  StreamSockets must be connected before
+       data can be sent and received.  Returns 0 if the connection was successfully
+       established, 1 if it's in progress.
+       
+       If the socket is non-blocking, this function may return before the
+       connection is fully established.  The caller must then use either the
+       poll_connect function or an EventDispatcher to finish the process. */
+       virtual bool connect(const SockAddr &);
 
-       StreamSocket(SocketHandle, const SockAddr &);
+       virtual bool poll_connect(const Time::TimeDelta &);
+
+private:
        void on_event(IO::PollEvent);
 };