open socket with message doesn't call the message

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
dglass
Posts: 519
Joined: Thu Sep 24, 2009 9:10 pm
Location: California
Contact:

open socket with message doesn't call the message

Post by dglass » Sat Apr 30, 2011 6:08 am

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?

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

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

Post by bangkok » Sat Apr 30, 2011 8:18 am

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...

dglass
Posts: 519
Joined: Thu Sep 24, 2009 9:10 pm
Location: California
Contact:

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

Post by dglass » Sat Apr 30, 2011 8:28 am

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. :)

Post Reply

Return to “Internet”