         tcpclose(socket)
         return true
     }
-    
+
     func getSocket() throws -> tcpsock {
         guard let socket = self.socket else {
-            throw TCPError.closedSocket(description: "Socket has not been initialized. You must first open to the socket.")
+            throw TCPError.closedSocket(description: "Connection has not been initialized. You must first open to the connection.")
+        }
+        if socket == nil {
+            throw TCPError.closedSocket(description: "Connection has not been initialized. You must first open to the connection.")
         }
         return socket
     }
-    
+
     func assertNotClosed() throws {
         if closed {
             throw TCPError.closedSocketError
         }
     }
-    
+
     deinit {
         if let socket = socket where !closed {
             tcpclose(socket)

            throw TCPError.unknown(description: "Port was not defined in URI")
        }
        socket = tcpconnect(try IP(remoteAddress: host, port: port).address, never)
    }
    
    
    public func receive(max byteCount: Int) throws -> C7.Data {
        return try receive(upTo: byteCount, timingOut: never)
    }
    
    public func send(data: C7.Data) throws {
        try send(data, flushing: true, deadline: never)
    }
    
    public func flush() throws {
        try flush(timingOut: never)
    }

        let result = try receive(upTo: codeUnitCount, until: delimiter, timingOut: deadline)
        return try String(data: result)
    }
}
