Here is a sample to give you some ideas and get you started
This is a simple add 'zb_tcp.py'. You will need to modify the script to include the port you want to use, and the EUI of your XBee, but it will create a socket for a single XBee and present a data connection as a TCP socket.
This is presented as-is, as a sample of how this can be achieved. Use at your own risk.
Edited: I was going to present a second sample, but I can't seem to find it now.