Board index » delphi » TCPIP Server "Tagging connections"?

TCPIP Server "Tagging connections"?

Hi

I use the TCPIP Server (Indy, of course :)

When i client tries to connect to the TCPIP server the server event
OnConnect is triggerd. What i want to do here is to "tag" the connection
(AThread) so that when the clients starts to send stuff to the server i will
now that itt is the "Tagged" client. I know that the IP number is unique
but i am no TCPIP "freak" :) so i dont know how unique Ips are. I know
about masked Ip numbers so i decided to "tag" the AThread my self so it will
be unique but how do i do this?

Thanx In Advance
Romeo

 

Re:TCPIP Server "Tagging connections"?


Basically hang a simple object off the DATA property ot the
AThread.connection ... there is an example of how to do this in the CHAT
demo.

/A.
(ps: reminder to all about the Live Q&A ./ Meat Indy Core on Monday night!)

Quote
"Romeo I" <romeo_isaks...@hotmail.com> wrote in message

news:3d4c5892_1@dnews...
Quote
> Hi

> I use the TCPIP Server (Indy, of course :)

> When i client tries to connect to the TCPIP server the server event
> OnConnect is triggerd. What i want to do here is to "tag" the connection
> (AThread) so that when the clients starts to send stuff to the server i
will
> now that itt is the "Tagged" client. I know that the IP number is unique
> but i am no TCPIP "freak" :) so i dont know how unique Ips are. I know
> about masked Ip numbers so i decided to "tag" the AThread my self so it
will
> be unique but how do i do this?

> Thanx In Advance
> Romeo

Re:TCPIP Server "Tagging connections"?


User the IP address Port combo ie FULL IP address
192.168.1.243:2345
You need to to it this way because it is possible to have more than one
client on the same IP, and in that situation each connection has to have a
diferent local port.
You would do something like(Indy 9):

peerIP              :=
TIdIOHandlerSocket(athread.Connection.IOHandler).Binding.peerip;
peerPort           :=
intTostr(TIdIOHandlerSocket(athread.Connection.IOHandler).Binding.peerport);
FullIP:= peerIP+':'+peerPort

This combo will be unique for each connection

remember to add IdIOHandlerSocket to your uses.

Quote
"Romeo I" <romeo_isaks...@hotmail.com> wrote in message

news:3d4c5892_1@dnews...
Quote
> Hi

> I use the TCPIP Server (Indy, of course :)

> When i client tries to connect to the TCPIP server the server event
> OnConnect is triggerd. What i want to do here is to "tag" the connection
> (AThread) so that when the clients starts to send stuff to the server i
will
> now that itt is the "Tagged" client. I know that the IP number is unique
> but i am no TCPIP "freak" :) so i dont know how unique Ips are. I know
> about masked Ip numbers so i decided to "tag" the AThread my self so it
will
> be unique but how do i do this?

> Thanx In Advance
> Romeo

Re:TCPIP Server "Tagging connections"?


You can also use the thread ID as a unique identifier.  That will be unique
to your machine.  It will save you a few bytes over using the IP/Port
combination.  Alternatively, you could encode the IP as a 4 bytes rather
than as a string and then encode the port for a total of 6 bytes.

But, it's all overkill unless you pass information out of your server and
then expect the reply to find its way back to the original session.  In that
case, you must provide a means to identify the return path.

Charles

Quote
"Romeo I" <romeo_isaks...@hotmail.com> wrote in message

news:3d4c5892_1@dnews...
Quote
> Hi

> I use the TCPIP Server (Indy, of course :)

> When i client tries to connect to the TCPIP server the server event
> OnConnect is triggerd. What i want to do here is to "tag" the connection
> (AThread) so that when the clients starts to send stuff to the server i
will
> now that itt is the "Tagged" client. I know that the IP number is unique
> but i am no TCPIP "freak" :) so i dont know how unique Ips are. I know
> about masked Ip numbers so i decided to "tag" the AThread my self so it
will
> be unique but how do i do this?

> Thanx In Advance
> Romeo

Other Threads