KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

Sockets - Crash after form loses focus
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    KiXforms Forum Index -> Discussion
View previous topic :: View next topic  
Author Message
Bonji
KiXforms Aficionado
KiXforms Aficionado


Joined: 10 Mar 2003
Posts: 393
Location: Virginia

PostPosted: Fri Aug 06, 2004 1:39 pm    Post subject: Sockets - Crash after form loses focus Reply with quote

I am finally able to reproduce this error consistantly.

When I am using the socket client (modified slightly to return the server's handle) the script will crash after the form loses focus. To make this happen I make a connection, disconnect, and then reconnect. After doing this the form stays open as long as I don't make it lose focus by clicking on another application. As soon as I do this, the script crashes.

Any thoughts on this? I'll include my client code just in case I screwed something up.

Code:

BREAK ON

$ADDRESS = "x.x.x.x"
$PORT = 777

$SYSTEM         = CREATEOBJECT("KIXTART.SYSTEM")

$FORM         = $SYSTEM.FORM()
$FORM.SIZE      = 420,190
$FORM.LOCATION      = 600,20
$FORM.FONT      = $SYSTEM.FONT("VERDANA",10)
$FORM.TEXT      = "Echo Client"
$lblSERVIP      = $FORM.LABEL("Server IP:")
$lblSERVIP.SIZE      = 90,21
$lblSERVIP.LOCATION   = 10,12
$txtSERVIP      = $FORM.TEXTBOX()
$txtSERVIP.SIZE      = 180,21
$txtSERVIP.LOCATION   = 110,10
$txtSERVIP.TEXT      = $ADDRESS
$lblSERVPORT      = $FORM.LABEL("Server Port:")
$lblSERVPORT.SIZE   = 90,21
$lblSERVPORT.LOCATION   = 10,42
$txtSERVPORT      = $FORM.TEXTBOX()
$txtSERVPORT.SIZE   = 180,21
$txtSERVPORT.LOCATION   = 110,40
$txtSERVPORT.TEXT   = $PORT
$lblSEND      = $FORM.LABEL("Send:")
$lblSEND.SIZE      = 90,21
$lblSEND.LOCATION   = 10,72
$txtSEND      = $FORM.TEXTBOX()
$txtSEND.SIZE      = 180,21
$txtSEND.LOCATION   = 110,70
$txtSEND.TEXT      = "MSG1"
$lblRECEIVE      = $FORM.LABEL("Receive:")
$lblRECEIVE.SIZE   = 90,21
$lblRECEIVE.LOCATION   = 10,102
$txtRECEIVE      = $FORM.TEXTBOX()
$txtRECEIVE.SIZE   = 180,21
$txtRECEIVE.LOCATION   = 110,100
$txtRECEIVE.LOCKED   = 1
$lblHANDLE      = $FORM.LABEL("Handle:")
$lblHANDLE.SIZE      = 90,21
$lblHANDLE.LOCATION   = 10,132
$txtHANDLE      = $FORM.TEXTBOX()
$txtHANDLE.SIZE      = 180,21
$txtHANDLE.LOCATION   = 110,130
$txtHANDLE.LOCKED   = 1
$cmdCONNECT      = $FORM.BUTTON()
$cmdCONNECT.SIZE   = 90,21
$cmdCONNECT.LOCATION   = 310,10
$cmdCONNECT.TEXT   = "Connect"
$cmdCONNECT.ONCLICK   = "cmdCONNECT_ONCLICK()"
$cmdDISCONNECT      = $FORM.BUTTON()
$cmdDISCONNECT.SIZE   = 90,21
$cmdDISCONNECT.LOCATION   = 310,40
$cmdDISCONNECT.TEXT   = "Disconnect"
$cmdDISCONNECT.ONCLICK   = "cmdDISCONNECT_ONCLICK()"
$cmdDISCONNECT.ENABLED   = 0
$cmdSEND      = $FORM.BUTTON()
$cmdSEND.SIZE      = 90,21
$cmdSEND.LOCATION   = 310,70
$cmdSEND.TEXT      = "Send"
$cmdSEND.ONCLICK   = "cmdSEND_ONCLICK()"
$cmdSEND.ENABLED   = 0
$cmdSEND.DEFAULT   = 1

$ = $FORM.SHOW
$ = $txtSEND.FOCUS()

WHILE $FORM.VISIBLE
   $ = EXECUTE($FORM.DOEVENTS)
LOOP

EXIT 1

FUNCTION cmdCONNECT_ONCLICK()
   $SOCKET = $SYSTEM.SOCKET()
   IF $SOCKET
      $ = $SOCKET.CONNECT($txtSERVIP.TEXT, $txtSERVPORT.TEXT)
      $cmdCONNECT.ENABLED = 0
      $cmdSEND.ENABLED = 1
      $cmdDISCONNECT.ENABLED = 1
      $ = $cmdSEND.FOCUS()
      $SOCKET.ONDISCONNECT = "evtDISCONNECT($$SYSTEM.EVENTOBJECT)"
      $SOCKET.ONRECEIVE = "evtRECEIVE($$SYSTEM.EVENTOBJECT)"
   ENDIF
ENDFUNCTION

FUNCTION evtDISCONNECT($SOCKET)
   $ = $FORM.MSGBOX("The connection has been lost.","Network Error")
   cmdDISCONNECT_ONCLICK()
ENDFUNCTION

FUNCTION evtRECEIVE($SOCKET)
   DIM $DATA
   $DATA = $SOCKET.RECEIVE()
   IF SUBSTR($DATA,1,4) = "{{}}"
      $txtHANDLE.TEXT = SUBSTR($DATA,5,LEN($DATA) - 4)
   ELSE
      $txtRECEIVE.TEXT = $SOCKET.RECEIVE()
   ENDIF
ENDFUNCTION

FUNCTION cmdSEND_ONCLICK()
   IF $SOCKET
      $SOCKET.SEND($txtSEND.TEXT)
   ENDIF
ENDFUNCTION

FUNCTION cmdDISCONNECT_ONCLICK()
   IF $SOCKET
      $SOCKET.DISCONNECT()
      $cmdCONNECT.ENABLED = 1
      $cmdSEND.ENABLED = 0
      $cmdDISCONNECT.ENABLED = 0
      $ = $cmdCONNECT.FOCUS()
   ENDIF
ENDFUNCTION

_________________
-Ben
Back to top
View user's profile Send private message
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Fri Aug 06, 2004 1:42 pm    Post subject: Reply with quote

nice clean script, you da man Ben.
_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Fri Aug 06, 2004 1:45 pm    Post subject: Reply with quote

apart from it maybe is a bit too 'LOUD'

Well, maybe because I prefer lowercase scripting as I get my syntax highlighted Wink

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Fri Aug 06, 2004 1:48 pm    Post subject: Reply with quote

I think you should wait until Shawn posts the next RC build (promised for todays evening)
_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Bonji
KiXforms Aficionado
KiXforms Aficionado


Joined: 10 Mar 2003
Posts: 393
Location: Virginia

PostPosted: Fri Aug 06, 2004 1:49 pm    Post subject: Reply with quote

Embarassed I feel all funny inside.

I like 3 letters to prefix the variables (I need to do this with all types) and having those lowercase and everything else uppercase helps me find that stuff better. Of course, I do use notepad for all my scripting.

_________________
-Ben


Last edited by Bonji on Fri Aug 06, 2004 1:51 pm; edited 2 times in total
Back to top
View user's profile Send private message
Lonkero
KiXforms Devotee
KiXforms Devotee


Joined: 13 Mar 2003
Posts: 1022
Location: Espoo, Finland

PostPosted: Fri Aug 06, 2004 1:49 pm    Post subject: Reply with quote

ja, looks little batchy.
I prefer lowercase just because there is nothing special in something small in script.
they all matter the same.

only that after I create a huge name I use uppercase between words (ucase the middle word's first letter) but that's all.

_________________
Hammer
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Bonji
KiXforms Aficionado
KiXforms Aficionado


Joined: 10 Mar 2003
Posts: 393
Location: Virginia

PostPosted: Fri Aug 06, 2004 1:53 pm    Post subject: Reply with quote

The problem with my way of doing it is I have to really scream something if I want it to stand out...

i.e.

Code:

;*****************
;*****************
; ARRRGGGHHHH!!!!!
;*****************
;*****************


Hmm...have I hijacked my own thread?

_________________
-Ben
Back to top
View user's profile Send private message
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Fri Aug 06, 2004 1:59 pm    Post subject: Reply with quote

Laughing
_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Fri Aug 06, 2004 2:18 pm    Post subject: Reply with quote

Ben - think i had the same problem a few days ago - it had to do with the queuing of events actually, think what was happening was that a socket event happened, and recorded the EventObject, then a form LostFocus happened and over-rode the event (remember the "one event" thingy), then things just went south ...

Anyway, haven't run your script yet - but I will shortly - I suspect that this is already fixed ... will advise ...
Back to top
View user's profile Send private message
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Fri Aug 06, 2004 2:35 pm    Post subject: Reply with quote

Shawn wrote:
then things just went south ...


This is the Canadian way to tell something's just went wrong, eh ?

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Chris S.
KiXforms Enthusiast
KiXforms Enthusiast


Joined: 05 Mar 2003
Posts: 241

PostPosted: Fri Aug 06, 2004 2:49 pm    Post subject: Reply with quote

Jochen wrote:
Shawn wrote:
then things just went south ...


This is the Canadian way to tell something's just went wrong, eh ?


As I live just a few hours south of Mr. Tassie, I take exception to that comment. Razz
Back to top
View user's profile Send private message MSN Messenger
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Fri Aug 06, 2004 2:56 pm    Post subject: Reply with quote

rofl, i meant to say "south of Ohio..."
Back to top
View user's profile Send private message
Bonji
KiXforms Aficionado
KiXforms Aficionado


Joined: 10 Mar 2003
Posts: 393
Location: Virginia

PostPosted: Fri Aug 06, 2004 2:59 pm    Post subject: Reply with quote

I live south of Ohio, yet somehow I am not offended. Geek
_________________
-Ben
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Fri Aug 06, 2004 3:09 pm    Post subject: Reply with quote

I'm talking way south now ... like Argentina.
Back to top
View user's profile Send private message
Bryce
KiXforms Supporter
KiXforms Supporter


Joined: 26 Mar 2003
Posts: 69

PostPosted: Fri Aug 06, 2004 3:10 pm    Post subject: Reply with quote

Bonji wrote:
I live south of Ohio, yet somehow I am not offended. Geek


me too! when i hear south.... i think mexico...... or the gulf of mexico....
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Discussion All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group