openSockets strangeness

Russell Martin russell_martin at yahoo.com
Sun Oct 12 16:42:56 EDT 2008


Hi. I've been playing around with sockets. I'm attempting to create a stack than can run shell commands on OS X so that I can get a multi-threaded effect.

I've never used sockets before, so after, digging through the chat example stack, I dug right in.

I'm finding some odd behavior that I'm hoping someone out there can shed some light on.

Question #1
===========
The first thing I discovered, was that when I attempt to open the connection as follows:
  open socket to "127.0.0.1:10261" with message socketConnected

The socketConnected handler gets triggered, even if the listening stack isn't open and listening. Also, unless I put a "wait" line in the socketConnected handler, calling the openSockets function returns:
  127.0.0.1:10261

This happens even though the socket didn't really get connected. Now, if I put even a 1 millisecond wait in the socketConnected handler:
  wait 1 millisecond

then calling "the openSockets" returns empty (as it should).

But, shouldn't my socketError handler have gotten triggered instead?

Question #2:
============
If my listening stack is open and the connection is made, then while the connection is up, calling the openSockets funtion returns 3 lines such as the following:
  10261
  127.0.0.1:10261
  127.0.0.1:57219

Does anyone have any idea why it isn't simply:
  127.0.0.1:10261

What are those 10261 and 127.0.0.1:57xxx lines all about? Does the IDE use that 57xxx (I've noticed that it is so far in the 57000 range) for it's own purposes?

Note: all of the described behavior is happening in the 3.0 IDE running on OS X 10.5.5.

Thanks in advance for any insight or ideas. :-]


      



More information about the use-livecode mailing list