Index: src/OFTCPSocket.h ================================================================== --- src/OFTCPSocket.h +++ src/OFTCPSocket.h @@ -34,11 +34,11 @@ * 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; + BOOL isListening; struct sockaddr *sockAddr; socklen_t sockAddrLen; } /** @@ -86,9 +86,14 @@ - (void)setKeepAlivesEnabled: (BOOL)enable; /** * Returns the remote address of the socket. Only works with accepted sockets! * - * \return The remote address as a string. + * \return The remote address as a string */ - (OFString*)remoteAddress; + +/** + * \return Whether the socket is a listening socket + */ +- (BOOL)isListening; @end Index: src/OFTCPSocket.m ================================================================== --- src/OFTCPSocket.m +++ src/OFTCPSocket.m @@ -326,11 +326,11 @@ if (listen(sock, backlog) == -1) @throw [OFListenFailedException newWithClass: isa socket: self backLog: backlog]; - listening = YES; + isListening = YES; } - (void)listen { if (sock == INVALID_SOCKET) @@ -340,11 +340,11 @@ if (listen(sock, 5) == -1) @throw [OFListenFailedException newWithClass: isa socket: self backLog: 5]; - listening = YES; + isListening = YES; } - (OFTCPSocket*)accept { OFTCPSocket *newsock; @@ -426,16 +426,21 @@ #endif /* Get rid of a warning, never reached anyway */ assert(0); } + +- (BOOL)isListening +{ + return isListening; +} - (void)close { [super close]; - listening = NO; + isListening = NO; [self freeMemory: sockAddr]; sockAddr = NULL; sockAddrLen = 0; } @end