Establishing a p2p connection in python
Jeremy Jones
zanesdad at bellsouth.net
Fri Oct 8 08:06:48 EDT 2004
gs wrote:
>Hi!
>
>This is my first time posting to a newsgroup so please be gentle to me
>:)
>
>
>
Welcome. You have little to fear from this crowd.
>Introduction to my problem:
>
>
>
<snip>
I think that your problem can be solved with Twisted. That is _a_
solution. Not the only, maybe not the best for everything you're
wanting to do (which it seems that learning a lot is important to you),
but _a_ solution. It's got a bit of a learning curve to wrap your head
around how everything fits together, but it's a powerful framework.
I've used it less than I plan to, but I've got some interest in how it
works.
>Problems:
>1) I've written a threaded server that stores information about
>connected servers in a "container class". This class holds information
>about username, a unique ID, the connecting adress and the actual
>socket. I have not been able to find any information online on how i
>could go about to connect two sockets. It would seem like the socket
>is already "occupied" since it is connected to the server. Could one
>duplicate, or otherwise get a dedicated socket for sending binary
>data, to one connected socket from another? A few pointers and/or tips
>would be greatly appreciated!
>
>
Are you talking about your server binding two different ports? If you
are using the Python standard SocketServer, you should be able to just
spin off a thread for each server you start and tell it to
serve_forever() (or what have you). If you're using Twisted, I think
all you would need to do is factory.listenTCP(<port number>, <factory>),
then reactor.run(). I'll leave getting data between the different ports
you've bound as an exercise for the reader.
>2) I've also failed to find python specific information on how abouts
>one would do file resuming. I would think that you, somehow, use
>md5-checksums to check file status and somehow skip the first part of
>the datastream. Also, pointers and maybe an explanation in (short)
>pseudo-code would be much appreciated.
>
>
Can't help you here, sorry.
>3) Is this too big of a project for a novice programmer such as
>myself? I do want to go through with this since it's a genuine
>problem, but i do not know if i'm ready. I'm not a "quitter" per say,
>but i'm afraid doing something TOO advanced in the beginning might be
>overwhelming :)
>
>
I don't think this is too big at all. But I do think you'll want to
break it down a little bit and set smaller goals for yourself. Try to
first get the smallest fairly usable thing working. Then you can start
adding functionality from there.
>Thanks for reading,
>gs
>
>
HTH,
Jeremy Jones
More information about the Python-list
mailing list