[Twisted-Python] Socket number

Christopher Armstrong radix at twistedmatrix.com
Sun Jun 10 11:51:06 EDT 2007

On 6/10/07, Simon Pickles <sipickles at hotmail.com> wrote:
> Hello,
> In my C++ game server, I used the socket number as the temporary ID of
> the connected player. Is there anyway to retrieve the socket number of a
> new player?
> Atm, I am just using self.transport.getPeer().host, but this is only the
> IP address, not socket.

If you only need this identifier for use in the implementation of the
server, a much better way to identify players is by their Protocol
object. On the other hand, if you do need to pass this identifier over
the wire, then I agree with Jean-Paul that a small incremental or
random number would be good.

Christopher Armstrong
International Man of Twistery

More information about the Twisted-Python mailing list