Page 1 of 1

open socket with message doesn't call the message

Posted: Sat Apr 30, 2011 6:08 am
by dglass
Given the following:

Code: Select all

   
on mouseup
open socket to strSocketConnection with message "connected"
end mouseUp

on connected theHost
   --connected so login
   put fld "fldUsername" into strUsername
   put the userPassword of fld "fldPassword" into strPassword
   write "*LOGIN::" & strUsername & "::" & strPassword to socket theHost
   set label of button "Connect" to "Disconnect"
   read from socket theHost with message "readSomething"
end connected
For some reason the 'open socket...' doesn't want to move on to the 'on connected' handler. I have a breakpoint in 'on connected' and I never get there.

If I move the stuff in 'on connected' into the mouseup (commenting the 'with message' portion of the 'open socket') it works, but it seems better to have the connection broken out into its own handler.

So, once again, what am I missing?

Re: open socket with message doesn't call the message

Posted: Sat Apr 30, 2011 8:18 am
by bangkok
dglass wrote:Given the following:

Code: Select all

   
on mouseup
open socket to strSocketConnection with message "connected"
end mouseUp
What about strSocketConnection ?

It should contains the IP address and the port number...

Re: open socket with message doesn't call the message

Posted: Sat Apr 30, 2011 8:28 am
by dglass
Yeah, sorry, I edited that code for brevity.

All the variables are valid; strSocketConnection is built in the full 'onMouseUp'.

I'm not sure what's different*, but it's working now without issue. I was getting ready to come back and post that, and got wrapped up in extending the functionality. :oops:

Thanks for taking the time to help. I appreciate it.

* - I think what was happening was that I wasn't closing the connection after each attempt, and was just rerunning all the stuff to open the socket. I would have thought that if that were the case, closing down LC, and restarting it would have forced a close though. It's also possible that I don't remember correctly all the steps I took while it was goofing up; it's very late here, and I should be in bed, but it's hard to stop when progress is being made. :)