@@ -31,11 +31,16 @@ #ifdef _WIN32 # include #endif +@class OFTCPSocket; @class OFString; + +#ifdef OF_HAVE_BLOCKS +typedef void (^of_tcpsocket_async_connect_block_t)(OFTCPSocket*); +#endif /** * \brief A class which provides functions to create and use TCP sockets. * * To connect to a server, create a socket and connect it. @@ -120,10 +125,23 @@ * \param host The host to connect to * \param port The port on the host to connect to */ - (void)connectToHost: (OFString*)host port: (uint16_t)port; + +#ifdef OF_HAVE_BLOCKS +/** + * \brief Asyncronously connect the OFTCPSocket to the specified destination. + * + * \param host The host to connect to + * \param port The port on the host to connect to + * \param block The block to execute once the connection has been established + */ +- (void)asyncConnectToHost: (OFString*)host + port: (uint16_t)port + block: (of_tcpsocket_async_connect_block_t)block; +#endif /** * \brief Bind the socket on the specified port and host. * * \param host The host to bind to. Use @"0.0.0.0" for IPv4 or @"::" for IPv6