@@ -35,31 +35,18 @@ * @param exception An exception which occurred while connecting the socket or * `nil` on success */ typedef void (^of_tcp_socket_async_connect_block_t)(OFTCPSocket *socket, id _Nullable exception); - -/*! - * @brief A block which is called when the socket accepted a connection. - * - * @param socket The socket which accepted the connection - * @param acceptedSocket The socket which has been accepted - * @param exception An exception which occurred while accepting the socket or - * `nil` on success - * @return A bool whether the same block should be used for the next incoming - * connection - */ -typedef bool (^of_tcp_socket_async_accept_block_t)(OFTCPSocket *socket, - OFTCPSocket *acceptedSocket, id _Nullable exception); #endif /*! * @protocol OFTCPSocketDelegate OFTCPSocket.h ObjFW/OFTCPSocket.h * * A delegate for OFTCPSocket. */ -@protocol OFTCPSocketDelegate +@protocol OFTCPSocketDelegate @optional /*! * @brief A method which is called when a socket connected. * * @param socket The socket which connected @@ -70,23 +57,10 @@ */ - (void)socket: (OFTCPSocket *)socket didConnectToHost: (OFString *)host port: (uint16_t)port exception: (nullable id)exception; - -/*! - * @brief A method which is called when a socket accepted a connection. - * - * @param socket The socket which accepted the connection - * @param acceptedSocket The socket which has been accepted - * @param exception An exception that occurred while accepting, or nil on - * success - * @return A bool whether to accept the next incoming connection - */ -- (bool)socket: (OFTCPSocket *)socket - didAcceptSocket: (OFTCPSocket *)acceptedSocket - exception: (nullable id)exception; @end /*! * @class OFTCPSocket OFTCPSocket.h ObjFW/OFTCPSocket.h * @@ -95,12 +69,10 @@ * To connect to a server, create a socket and connect it. * To create a server, create a socket, bind it and listen on it. */ @interface OFTCPSocket: OFStreamSocket { - bool _listening; - of_socket_address_t _remoteAddress; OFString *_Nullable _SOCKS5Host; uint16_t _SOCKS5Port; #ifdef OF_WII uint16_t _port; #endif @@ -110,22 +82,10 @@ #ifdef OF_HAVE_CLASS_PROPERTIES @property (class, nullable, copy, nonatomic) OFString *SOCKS5Host; @property (class, nonatomic) uint16_t SOCKS5Port; #endif -/*! - * @brief Whether the socket is a listening socket. - */ -@property (readonly, nonatomic, getter=isListening) bool listening; - -/*! - * @brief The remote address. - * - * @note This only works for accepted sockets! - */ -@property (readonly, nonatomic) const of_socket_address_t *remoteAddress; - #if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) /*! * @brief Whether keep alives are enabled for the connection. * * @warning This is not available on the Wii or Nintendo 3DS! @@ -137,11 +97,11 @@ /*! * @brief Whether TCP_NODELAY is enabled for the connection * * @warning This is not available on the Wii! */ -@property (nonatomic, getter=isTCPNoDelayEnabled) bool TCPNoDelayEnabled; +@property (nonatomic, getter=isNoDelayEnabled) bool noDelayEnabled; #endif /*! * @brief The host to use as a SOCKS5 proxy. */ @@ -254,63 +214,10 @@ * chosen, which can be obtained using the return value. * @return The port the socket was bound to */ - (uint16_t)bindToHost: (OFString *)host port: (uint16_t)port; - -/*! - * @brief Listen on the socket. - * - * @param backlog Maximum length for the queue of pending connections. - */ -- (void)listenWithBacklog: (int)backlog; - -/*! - * @brief Listen on the socket. - */ -- (void)listen; - -/*! - * @brief Accept an incoming connection. - * - * @return An autoreleased OFTCPSocket for the accepted connection. - */ -- (instancetype)accept; - -/*! - * @brief Asynchronously accept an incoming connection. - */ -- (void)asyncAccept; - -/*! - * @brief Asynchronously accept an incoming connection. - * - * @param runLoopMode The run loop mode in which to perform the async accept - */ -- (void)asyncAcceptWithRunLoopMode: (of_run_loop_mode_t)runLoopMode; - -#ifdef OF_HAVE_BLOCKS -/*! - * @brief Asynchronously accept an incoming connection. - * - * @param block The block to execute when a new connection has been accepted. - * Returns whether the next incoming connection should be accepted - * by the specified block as well. - */ -- (void)asyncAcceptWithBlock: (of_tcp_socket_async_accept_block_t)block; - -/*! - * @brief Asynchronously accept an incoming connection. - * - * @param runLoopMode The run loop mode in which to perform the async accept - * @param block The block to execute when a new connection has been accepted. - * Returns whether the next incoming connection should be accepted - * by the specified block as well. - */ -- (void)asyncAcceptWithRunLoopMode: (of_run_loop_mode_t)runLoopMode - block: (of_tcp_socket_async_accept_block_t)block; -#endif @end #ifdef __cplusplus extern "C" { #endif