modal function of a modal operator is never called I want to receive real time data into blender based on which I would control some animation. To receive the real time data I am using a datagram socket with a modal operator. But for some reason the modal function of the operator is never getting called 

Here is the code for my operator 

import bpy
import socket
import os
import sys

absolutePath = "/Users/pulkitjuneja/Documents/projects/EVA/scripts"
sys.path.append(absolutePath)

from animationController import main


class socketModal(bpy.types.Operator):
    bl_idname = "object.modal_operator"
    bl_label = "Lip synch Operator"

    def __init__(self):
        print("Listen Start")
        os.chdir(absolutePath)
        self.port = 1301

    def __del__(self):
        print("Listen End")

    def execute(self, context):
        print("execute")
        return {'RUNNING_MODAL'}

    def invoke(self, context, event):
        self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        self.socket.setblocking(0)
        self.socket.bind(("127.0.0.1", self.port))
        self.execute(context)
        print('socket listening on port', self.port)
        context.window_manager.modal_handler_add(self)
        return {'RUNNING_MODAL'}

    def modal(self, context, event):
        data = None
        try:
            data = self.socket.recv(1024 * 1024)
         except socket.error:
            print('no data')
        print(data)
        print("here")
        if event.type == 'BACK_SLASH':
            self.socket.close()
            return {'FINISHED'}
        return {'RUNNING_MODAL'}


bpy.utils.register_class(socketModal)
bpy.ops.object.modal_operator('INVOKE_DEFAULT')


I am running this script inside blender to register and run the operator but only the invoke function seems to be called. Is there anything I am doing wrong ?
This is a bit late, but, at present, the modal operator will be invoked at every(!) blender event. This is perhaps not what you want, and could be the source of your problems. A better idea for such operators is to be restricted to particular events. For example, you could start a timer that triggers every 1 second:

bpy.context.window_manager.event_timer_add(1, bpy.context.window)


And, in your modal function, have:

def modal(self, context, event):
    if event.type == 'TIMER':
        # do something
    return {'RUNNING_MODAL'}