on 1/2/01 3:10 PM, [EMAIL PROTECTED] at
[EMAIL PROTECTED] wrote:

> I'm working on a chat program, bolstered by the help
> of others on the list. I want to get the IP address of
> the person chatting with me, even if they don't know
> how to get it themselves. I investigated hostAddress
> and peerAddress but ran into a puzzle -- can anyone
> explain it?

I have looked into this again and have found that:

put peerAddress(s) into field "whatever"

will also get the other person's ip number.  This is much cleaner than the
other way I just posted.  The key for us newbies is to understand that the
"s" variable is the part that we miss.  You must use the variable that you
chose at the beginning of the handler that does the reading.  For example, I
used this:  

on openCard
  put field "port" into iPort
  accept connections on port iPort with message "newconnect"
end openCard

on newconnect s
  --FIGURE OUT THE LENGTH OF THE MESSAGE
  read from socket s for 1 line
  put it into tLength
  
  --NOW READ FOR THE SPECIFIED LENGTH OF THE MESSAGE
  read from socket s for tLength
  
  put peerAddress(s)
...
...
end newconnect

-Mark Talluto


Archives: http://www.mail-archive.com/[email protected]/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.

Reply via email to