Hi all, 

I'm trying to develop a bundle for communicating with a TCP server, and would like to create 1) a bundle command that opens the connection, and 2) other commands that use that connection object (eg via grabbing text selection in the editor window).

In Python, I've created a bundle command like this: 

import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

HOST = "127.0.0.1"
PORT = 7098

sock.connect((HOST, PORT))

sock.send("some command...")
print sock.recv(512)

That sets up the socket correctly, in fact you can send messages to the TCP server.

However each time I send a command, the socket is obviously re-created; I wondered if I TextMate provides a mechanism to save the 'sock' binding in the current  environment - so that I can reuse it later within other commands.

Hope this makes sense - thanks in advance for any help. 

Mike