@@ -53,18 +53,10 @@ saddr = NULL; return self; } -- (void)dealloc -{ - if (sock != INVALID_SOCKET) - close(sock); - - [super dealloc]; -} - - connectToService: (OFString*)service onNode: (OFString*)node { if (sock != INVALID_SOCKET) @throw [OFAlreadyConnectedException newWithClass: isa]; @@ -381,13 +373,23 @@ - close { if (sock == INVALID_SOCKET) @throw [OFNotConnectedException newWithClass: isa]; - [self freeMemory: saddr]; + close(sock); sock = INVALID_SOCKET; + + [self freeMemory: saddr]; saddr = NULL; saddr_len = 0; return self; } + +- (void)dealloc +{ + if (sock != INVALID_SOCKET) + [self close]; + + [super dealloc]; +} @end