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> <<a href="mailto:exarkun@divmod.com">exarkun@divmod.com</a>> 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 <<a href="mailto:johna@johnaherne.co.uk">johna@johnaherne.co.uk</a>> wrote:<br>>I am looking at using PDA devices talking to a server over gprs.<br>><br>>I need to push data to the PDA over elapsed timeframes that might be hours.
<br>>Naturally during this timespan the device may have been dropped from the<br>>network or acquire a different IP address.<br>><br>>However to push data to the PDA, I need to record the IP and port used by<br>
>the PDA for its first contact since it is stuck behind a firewall.<br>><br>>The socket needs to be kept open on the PDA so the server can keep<br>>responding on the same session over a period of time.<br>>
<br>>Using straight sockets I can do this by holding the reference to the IP/port<br>>used by the PDA. And checking every now and then that the connection is<br>>still valid. But I am no comms expert and I need to keep track of over 100
<br>>devices and keep reliably sending messages to them at random intervals.<br>><br>>So, I thought it might be better to use some framework for the server since<br>>I am no expert on sockets.<br>><br>>But looking through the docs for twisted and some of the code, I can't see
<br>>anywhere how I can get and use a reference to the port and reuse the open<br>>session on the PDA.<br>><br>>Can I do this with twisted or should I look for some other way of doing what<br>>I want.<br>>
<br>>I was thinking I could use irc with twisted but not sure if I am barking up<br>>the wrong tree.<br>><br>>Thanks for any ideas of solving the problem.<br>><br><br>It's not totally clear to me what you're after. Perhaps you could define
<br>some terms. What is a "session"? What kind of sockets are involved? What<br>does it mean to "hold a reference" 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