I am codig an aplication, I want when an user connects, the insim write a message using the /msg command to all conections, How I do it?
                
            
from socket import *
import struct
import string
import threading
import time
import math
import winsound
import random
import array
global s
global data
global msgs
msgs = []
global conntry
conntry = 0
s = socket()
insim_admin = ""
insim_ip = "127.0.0.1"
insim_port = 7776
insim_name = "MsgApp"
class InSimRecv(threading.Thread):
    
    def kill(self):
        self.killed = True
        
    def run(self):
        while 1:
            InSimData = s.recv(4096)
            InSimHeader = InSimData[0:3]
            if InSimData:
                if int(struct.unpack("B", InSimData[1])[0]) == 3:
                    s.send(struct.pack("BBBB", 4, 3, 0, 0))    #Send ACK
                if struct.unpack("B", InSimData[1])[0] == 18:
                    s.send(struct.pack("BBBBBBBB63sB", 72, 14, 0, 0, int(struct.unpack("B", InSimData[3])[0]), 0, 0, 0, "Welcome to the server, connection #" + str(int(struct.unpack("B", InSimData[3])[0])) + " !", 0))
class keepalive(threading.Thread):
    def run(self):
        #s.send(struct.pack("BBBB", 4, 3, 0, 0))    #Send ACK
        time.sleep(15)
    
    def kill(self):
        self.killed = True
class InSimConnect(threading.Thread):
    def run(self):
        conntry = 0
        while conntry < 5:
            try:
                conntry=conntry+1
                print "Connecting to " + insim_ip + " on port " + str(insim_port) + "(" + str(conntry) +  "/5)"
                s.connect( ("127.0.0.1", 777) )
            except:
                print "Connection Failed!"
                pass
        time.sleep(1)
            
        try:
            s.send(struct.pack("BBBBhhBsh16s16s", 44, 1, 0, 0, 0, 32, 0, "!", 10, insim_admin, insim_name))
            s.send(data)
            time.sleep(1)
            
            InSimRecv().start()
            InSimMsgRotate().start()
            keepalive().start()
            conntry = 999
            s.send(struct.pack("BBBB64s", 68, 13, 0, 0, "/msg ^5wheel4hummer\'s message app started."))
        except:
            print "Unknown Error"
            pass
                
        if conntry < 999:
            print "All connection attempts failed!"
InSimConnect().start()