         unless callback?
             return
 
+        result = @_parseIOMessage message
+
+        if result?
+            callback result
+
+
+    _isValidMessage: (message) ->
+        unless message?
+            console.log 'Invalid message: null'
+            return false
+
+        unless message.content?
+            console.log 'Invalid message: Missing content'
+            return false
+
+        if message.content.execution_state is 'starting'
+            # Kernels send a starting status message with an empty parent_header
+            console.log 'Dropped starting status IO message'
+            return false
+
+        unless message.parent_header?
+            console.log 'Invalid message: Missing parent_header'
+            return false
+
+        unless message.parent_header.msg_id?
+            console.log 'Invalid message: Missing parent_header.msg_id'
+            return false
+
+        unless message.parent_header.msg_type?
+            console.log 'Invalid message: Missing parent_header.msg_type'
+            return false
+
+        unless message.header?
+            console.log 'Invalid message: Missing header'
+            return false
+
+        unless message.header.msg_id?
+            console.log 'Invalid message: Missing header.msg_id'
+            return false
+
+        unless message.header.msg_type?
+            console.log 'Invalid message: Missing header.msg_type'
+            return false
+
+        return true
+
+
+    _parseIOMessage: (message) ->
         result = @_parseDisplayIOMessage message
 
         unless result?

module.exports =
class Kernel
    constructor: (@kernelSpec, @grammar, @config, @configPath, @onlyConnect = false) ->
        console.log "Kernel spec:", @kernelSpec
        console.log "Kernel configuration:", @config
        console.log "Kernel configuration file path:", @configPath
        @language = @kernelSpec.grammarLanguage
        @kernelName = @kernelSpec.display_name
        @executionCallbacks = {}

        @ioSocket.close()

        if @onlyConnect
            detail = 'Shutdown request sent to custom kernel connection in ' +
                @configPath
            atom.notifications.addInfo 'Custom kernel connection:',
                detail: detail

        unless @onlyConnect
            @kernelProcess.kill 'SIGKILL'
