Hello.
I'm using asynchronous sockets in a multithreaded program
(much of the code for which was posted here a while back)
to handle my network connections. So far, I've only been tossing
back and forth simple Python objects (as strings), and all is good.
But now I want to begin transferring binary files as well.
Things are getting a bit cloudy. How I've handled the
received network events so far is to split them into a package containing
a header and content. On receiving the event, the app parses the header
and then deals appropriately with the content. It's pretty much a one shot deal.
Sending longer files seems problematic for several reasons (all, of course,
relating to my ignorance).
1. The async thread I'm using right now works for receiving events. I'm assuming
that for *sending* several events concurrently, I'll either need to use a similar implementation
or additional threads using new ports (i.e., 1 port for my longer file transfers, a different
port for instant messages, different threads for each...)?
2. Assuming the recipient doesn't want to receive the longer file... I need a way to
implement error handling (i.e., if the file size is too large, or for security reasons)- basically, the sender needs
to be able to 'fire a blank' to alert the recipient, the recipient needs to reply, yadda yadda
like FTP. If I am sending the event from one class instance and the "OK" is being picked up by another
thread instance, how do I then go ahead with the filetransfer?
I.E., With wxEvents, I'm able to send events *back to* a parent thread/window, but so
far I've had no luck forwarding incoming events from Main() to child windows that have
been instantiated and displayed using Show(true).. hmm.
3) this is more a python question, but I am assuming that in transferring files, I am going to
have to do something such as:
a) open file
b) readlines to python variable
c) send python variable w/filename
d) catch it and handle it appropriately.
Does this sound on target, or am I completely missing something here?
I need to get oriented here, because I'm definitely whirling.
just about any suggestion should prove useful at this point.
thanks.
Stephen