www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Socket identification key

reply "Jarl =?UTF-8?B?QW5kcsOpIg==?= <jarl.andre gmail.com> writes:
Hi

I have searched high and low to figure this one out. There does 
not seems to be a an accessible way of getting a unique key for a 
socket. I have learned that port numbers count a great deal but 
really shouldn't there be some internal numbering or 
representation of each socket that the developer can use in maps 
etc? Lets say I want to store statistics for each individual 
client, but I don't want the client to "log in" or something 
similiar. I want to automatically remember the handshake done by 
the underlying TCP connection.

Is it possible to retrieve a unique key for a given socket? If 
this has been discussed before it is very well hidden in the 
depths of asgar, so please then enlighten me.

Cheers.
May 31 2012
next sibling parent =?UTF-8?B?QWxleCBSw7hubmUgUGV0ZXJzZW4=?= <alex lycus.org> writes:
On 31-05-2012 16:44, "Jarl André" <jarl.andre gmail.com>" wrote:
 Hi

 I have searched high and low to figure this one out. There does not
 seems to be a an accessible way of getting a unique key for a socket. I
 have learned that port numbers count a great deal but really shouldn't
 there be some internal numbering or representation of each socket that
 the developer can use in maps etc? Lets say I want to store statistics
 for each individual client, but I don't want the client to "log in" or
 something similiar. I want to automatically remember the handshake done
 by the underlying TCP connection.

 Is it possible to retrieve a unique key for a given socket? If this has
 been discussed before it is very well hidden in the depths of asgar, so
 please then enlighten me.

 Cheers.

Your Socket object *is* the key. It's a reference, it has a memory address as value. -- Alex Rønne Petersen alex lycus.org http://lycus.org
May 31 2012
prev sibling next sibling parent "Jarl =?UTF-8?B?QW5kcsOpIg==?= <jarl.andre gmail.com> writes:
On Thursday, 31 May 2012 at 14:46:42 UTC, Alex Rønne Petersen
wrote:
 On 31-05-2012 16:44, "Jarl André" <jarl.andre gmail.com>" 
 wrote:
 Hi

 I have searched high and low to figure this one out. There 
 does not
 seems to be a an accessible way of getting a unique key for a 
 socket. I
 have learned that port numbers count a great deal but really 
 shouldn't
 there be some internal numbering or representation of each 
 socket that
 the developer can use in maps etc? Lets say I want to store 
 statistics
 for each individual client, but I don't want the client to 
 "log in" or
 something similiar. I want to automatically remember the 
 handshake done
 by the underlying TCP connection.

 Is it possible to retrieve a unique key for a given socket? If 
 this has
 been discussed before it is very well hidden in the depths of 
 asgar, so
 please then enlighten me.

 Cheers.

Your Socket object *is* the key. It's a reference, it has a memory address as value.

I don't know why but for some reason this did not come to my mind. LOL
May 31 2012
prev sibling parent "Jarl =?UTF-8?B?QW5kcsOpIg==?= <jarl.andre gmail.com> writes:
 I don't know why but for some reason this did not come to my
 mind. LOL

Its a bit embarassing really because I work with Java every day and memory reference is a core feature. But I think the SocketSet buzzed my brain making me think that it gave me different objects or something. But anyway, lets forget this mumbo jumbo question. I have updated my https://github.com/jarlah/d2-simple-socket-server with stateful overridable socket handlers, and to make it able to quickly setup the server I added a default one. So, I think my brain is straight again now. Just got a bit messed up by the api.
May 31 2012