Re: Establishing a p2p connection in python

From: Jeremy Jones (zanesdad_at_bellsouth.net)
Date: 10/08/04


Date: Fri, 08 Oct 2004 08:06:48 -0400
To: gs <gs.lists@gmail.com>

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



Relevant Pages

  • Re: How to terminate a socket in CLOSE_WAIT state
    ... FTP Server fixed for certain FTP clients who use both passive ... This was causing a PASSIVE opened socket to be left ... but instead expect the "half close" from the receiver. ... this sends a TCP/IP FIN packet to the ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Socket switch delay
    ... both at the client and at the server (and why ... would you set the send buffer size to zero on a non-overlapped ... One glaring error is your client does ... So when you use a single socket, ...
    (microsoft.public.win32.programmer.networks)
  • Re: Applet Hangs when submitting data to servlet
    ... to put a time limit on my socket connections and socket reads. ... public void setTimeoutthrows UnknownHostException, ... on our web server. ... private JButton theSubmitButton_, theClearButton_; ...
    (comp.lang.java.programmer)
  • Re: Problem with writing fast UDP server
    ... UDP packets per second. ... socket and threads. ... I wrote a simple case test: client and server. ... The maximum theoretical limit is 14,880 frames per ...
    (comp.lang.python)
  • Re: Socket Exception
    ... In this case the server most likely rejected your ... connection. ... Each command is a new socket connection that is opened and closed ... /// Required designer variable. ...
    (microsoft.public.win32.programmer.networks)