I have done some GPRS comms work with Python using asyncore and UDP sockets. I'm in the process, if someone would give me a charge number, of moving to Twisted as I am certain I can achieve the same goal in a much better design.
<br><br>I had the same problem with the IP address of the client (the PDA in your case). I used a polling design where each client routinely polled the server. Every time a poll comes from a client I grab the IP and port form the UDP header along with the client id embedded in the message. Saving this in a dictionary gave me an easy to use lookup for pushing data out to the client. You may need to get fancy with the dictionary. For example, I my add a time stamp the record so I know the last time the client sent a response. If a client has been down for some amount of time it could be removed the dictionary.
<br><br>So, you need:<br><br>1. Client has an id that it transmits with every message to the server<br>2. Client stores the server IP/PORT so it can poll independently.<br>3. RETRY LOGIC if you use UDP!!!<br><br>This has been deployed to the field server up to 3000 clients with a 25 second poll rate avg 22 bytes per message. In short, it works pretty well.
<br><br><div><span class="gmail_quote">On 1/7/07, <b class="gmail_sendername">Jean-Paul Calderone</b> &lt;<a href="mailto:exarkun@divmod.com">exarkun@divmod.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Sun, 07 Jan 2007 11:41:52 +0000, John Aherne &lt;<a href="mailto:johna@johnaherne.co.uk">johna@johnaherne.co.uk</a>&gt; wrote:<br>&gt;I am looking at using PDA devices talking to a server over gprs.<br>&gt;<br>&gt;I need to push data to the PDA over elapsed timeframes that might be hours.
<br>&gt;Naturally during this timespan the device may have been dropped from the<br>&gt;network or acquire a different IP address.<br>&gt;<br>&gt;However to push data to the PDA, I need to record the IP and port used by<br>
&gt;the PDA for its first contact since it is stuck behind a firewall.<br>&gt;<br>&gt;The socket needs to be kept open on the PDA so the server can keep<br>&gt;responding on the same session over a period of time.<br>&gt;
<br>&gt;Using straight sockets I can do this by holding the reference to the IP/port<br>&gt;used by the PDA. And checking every now and then that the connection is<br>&gt;still valid. But I am no comms expert and I need to keep track of over 100
<br>&gt;devices and keep reliably sending messages to them at random intervals.<br>&gt;<br>&gt;So, I thought it might be better to use some framework for the server since<br>&gt;I am no expert on sockets.<br>&gt;<br>&gt;But looking through the docs for twisted and some of the code, I can&#39;t see
<br>&gt;anywhere how I can get and use a reference to the port and reuse the open<br>&gt;session on the PDA.<br>&gt;<br>&gt;Can I do this with twisted or should I look for some other way of doing what<br>&gt;I want.<br>&gt;
<br>&gt;I was thinking I could use irc with twisted but not sure if I am barking up<br>&gt;the wrong tree.<br>&gt;<br>&gt;Thanks for any ideas of solving the problem.<br>&gt;<br><br>It&#39;s not totally clear to me what you&#39;re after.&nbsp;&nbsp;Perhaps you could define
<br>some terms.&nbsp;&nbsp;What is a &quot;session&quot;?&nbsp;&nbsp;What kind of sockets are involved?&nbsp;&nbsp;What<br>does it mean to &quot;hold a reference&quot; to an IP/port?<br><br>If I try to guess at the answers to these questions, then it sounds like
<br>a pretty straightforward problem involving multiple connections, which is<br>easily enough handled in Twisted.<br><br>Jean-Paul<br><br>_______________________________________________<br>Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br><a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
</a><br></blockquote></div><br><br clear="all"><br>-- <br><br>Sean Roark