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

Kixforms Sockets : Discussion II
Goto page Previous  1, 2, 3, 4  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: Sat Aug 07, 2004 12:13 am    Post subject: Reply with quote

Yay! $System.Error!!!!

The error I get is "A non-blocking socket operation could not be completed immediately."

Also, what is the name property for? Strictly an identification thing?

_________________
-Ben
Back to top
View user's profile Send private message
Bonji
KiXforms Aficionado
KiXforms Aficionado


Joined: 10 Mar 2003
Posts: 393
Location: Virginia

PostPosted: Sat Aug 07, 2004 12:18 am    Post subject: Reply with quote

I found my problem, I didn't change the blocking mode on the Listener socket. I need to stop watching TV while coding. Shocked
_________________
-Ben
Back to top
View user's profile Send private message
Bonji
KiXforms Aficionado
KiXforms Aficionado


Joined: 10 Mar 2003
Posts: 393
Location: Virginia

PostPosted: Sat Aug 07, 2004 12:41 am    Post subject: Reply with quote

The crashing problem is gone. I've got to figure out how to use the error messages now. Sometimes you get one when there really wasn't an error (more informational than anything). It seems to be a timing thing with the non-blocking sockets.

Is there a way to query to see if the socket is connected? $socket.connected kind of thing.

_________________
-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: Sat Aug 07, 2004 12:59 am    Post subject: Reply with quote

Ok - heres the deal ... this error here:

A non-blocking socket operation could not be completed immediately

is not really an error. In fact, for a while, i was supressing this "error". Basically what's its saying is that the operation didn't complete emmediately because your socket is non-blocking ... i myself have yet to see an non-blocking operation complete before the method returns ... even when client/server are on the same machine - but who knows.

The important thing is - should I maybe re-supress this "error" ? I put it back in for informational purposes and completeness - and because maybe it might be useful to know this - thing is, if your performing logic in your non-blocking event function, why would be be usefull to know that your operation completed when you called it ? Your logic is still buried in your event function, so you'll need to "get there" anyway ... ja ?

I was using the "Name" property for debugging purposes, it behaves somewhat like the Control.Name property - just a name holder. But usefull when tracking all these sockets.

-Shawn
Back to top
View user's profile Send private message
Bonji
KiXforms Aficionado
KiXforms Aficionado


Joined: 10 Mar 2003
Posts: 393
Location: Virginia

PostPosted: Sat Aug 07, 2004 1:17 am    Post subject: Reply with quote

It may not be a bad thing to leave this error for informational purposes. We will have to code around it, but it will be there in case we were to really need it.

[EDIT] Well, after working with it for a bit, I just realized this error doesn't do anything for us really because you get it whether or not the connection was made.

It may be that we make the connection, and then test to see if the connection exists. Does this make sense? If it does, I don't think we have a method to do that currently.

_________________
-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: Sat Aug 07, 2004 1:32 am    Post subject: Reply with quote

You mean this "Connected" property you refered to earlier - looking into this now ... btw, how do I get talking to telnet - i tried connecting to port 23 with little-kim there, but just got gobbledy-gook back ... got any code to share ?
Back to top
View user's profile Send private message
Shawn
KiXforms Developer
KiXforms Developer


Joined: 22 Feb 2003
Posts: 1983
Location: Canada

PostPosted: Sat Aug 07, 2004 1:35 am    Post subject: Reply with quote

btw - i'm thinking we don't need this "error". it might be pointless to know this, and one would have to keep "checking-around" it when error checking ... still thinking about. Wonder if SocketWrench suppresses it.
Back to top
View user's profile Send private message
Bonji
KiXforms Aficionado
KiXforms Aficionado


Joined: 10 Mar 2003
Posts: 393
Location: Virginia

PostPosted: Sat Aug 07, 2004 1:43 am    Post subject: Reply with quote

The server puts a carriage return after every character typed on the client, but other than that it works good.

Echo Server
Code:

BREAK ON

$LOCALIP = FORMAT_IP(@IPADDRESS0)
$PORT = 777

$SYSTEM = CREATEOBJECT("KIXTART.SYSTEM")

$FORM            = $SYSTEM.FORM()
$FORM.SIZE         = 400,300
$FORM.LOCATION         = 20,20
$FORM.FONT         = $SYSTEM.FONT("VERDANA",10)
$FORM.TEXT         = "Echo Server"
$FORM.DOCKPADDING      = 2,2,2,2
$mnuMENU         = $SYSTEM.MAINMENU()
$mnuMENU_FILE         = $mnuMENU.MENUITEMS.ADD("File")
$mnuMENU_FILE_EXIT      = $mnuMENU_FILE.MENUITEMS.ADD("Exit")
$mnuMENU_FILE_EXIT.ONCLICK   = "mnuMENU_FILE_EXIT_ONCLICK()"
$mnuMENU_EDIT         = $mnuMENU.MENUITEMS.ADD("Edit")
$mnuMENU_EDIT_CLEAR      = $mnuMENU_EDIT.MENUITEMS.ADD("Clear")
$mnuMENU_EDIT_CLEAR.ONCLICK   = "mnuMENU_EDIT_CLEAR_ONCLICK()"
$FORM.MENU         = $mnuMENU
$tlbTOOLBAR         = $FORM.GROUPBOX()
$tlbTOOLBAR.HEIGHT      = 20
$tlbTOOLBAR.DOCK      = "TOP"
$tlbSTART         = $tlbTOOLBAR.TOOLBUTTON()
$tlbSTART.WIDTH         = 20
$tlbSTART.ICON         = 34
$tlbSTART.TOOLTIPTEXT      = "Start the Listener"
$tlbSTART.DOCK         = "LEFT"
$tlbSTART.ONCLICK      = "tlbSTART_ONCLICK()"
$tlbSTOP         = $tlbTOOLBAR.TOOLBUTTON()
$tlbSTOP.WIDTH         = 20
$tlbSTOP.ICON         = 33
$tlbSTOP.TOOLTIPTEXT      = "Stop the Listener"
$tlbSTOP.DOCK         = "LEFT"
$tlbSTOP.ONCLICK      = "tlbSTOP_ONCLICK()"
$stsBAR            = $FORM.STATUSBAR
$stsBAR.DOCK         = "BOTTOM"
$lstCLIENTS         = $FORM.LISTBOX()
$lstCLIENTS.DOCK      = "LEFT"
$lstCLIENTS.ONCLICK      = "lstCLIENTS_ONCLICK()"
$splSPLITTER         = $FORM.SPLITTER()
$txtDETAILS         = $FORM.TEXTBOX()
$txtDETAILS.DOCK      = "FILL"
$txtDETAILS.MULTILINE      = 1

$SOCKETS         = $SYSTEM.COLLECTION()

$ = $FORM.SHOW
tlbSTART_ONCLICK()

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


FUNCTION evtACCEPT()
   DIM $SOCKET, $HANDLE
   $SOCKET = $LISTENER.ACCEPT()
   IF $SOCKET
      $SOCKET.BLOCKING = 0
      $SOCKET.ONRECEIVE = "evtRECEIVE($$SYSTEM.EVENTOBJECT)"
      $SOCKET.ONDISCONNECT = "evtDISCONNECT($$SYSTEM.EVENTOBJECT)"
      $SOCKETS.ADD($SOCKET)
      $ = $lstCLIENTS.ADDITEM(""+ $SOCKET.HANDLE + " : " + $SOCKET.ADDRESS)
      $HANDLE = $SOCKET.HANDLE
      $ = EXECUTE("$$CLIENT$HANDLE = $$SYSTEM.COLLECTION")
      ;Send server connection info to client
      $ = $SOCKET.SEND("{{}}" + $SOCKET.HANDLE)
   ENDIF
ENDFUNCTION

FUNCTION evtRECEIVE($SOCKET)
   DIM $TEXT
   $TEXT = $SOCKET.RECEIVE()
   $HANDLE = $SOCKET.HANDLE
   $ = EXECUTE("$$CLIENT$HANDLE.ADD('$TEXT')")
   $SOCKET.SEND($TEXT)
ENDFUNCTION

FUNCTION evtDISCONNECT($SOCKET)
   IF $CLEAR_HANDLES = ""
      $CLEAR_HANDLES = $HANDLE
   ELSE
      $CLEAR_HANDLES = "" + $CLEAR_HANDLES + ";" + $HANDLE
   ENDIF
   $HANDLE = $SOCKET.HANDLE
   $ = EXECUTE("$$CLIENT$HANDLE.ADD('<DISCONNECTED>')")
ENDFUNCTION

FUNCTION lstCLIENTS_ONCLICK()
   DIM $HANDLE, $INDEX, $TMPARRAY
   $INDEX = $lstCLIENTS.LISTINDEX
   $ = $txtDETAILS.CLEAR()
   IF $INDEX <> -1
      $HANDLE = $SOCKETS.ITEM($INDEX).HANDLE
      $ = EXECUTE("$$TMPARRAY = $$CLIENT$HANDLE")
      FOR EACH $ELEMENT IN $TMPARRAY
         $ = $txtDETAILS.APPENDTEXT($ELEMENT + @CRLF)
      NEXT
   ENDIF
ENDFUNCTION

FUNCTION mnuMENU_FILE_EXIT_ONCLICK()
   QUIT()
ENDFUNCTION

FUNCTION mnuMENU_EDIT_CLEAR_ONCLICK()
   DIM $CLEAR_HANDLES_ARRAY
   $lstCLIENTS.CLEAR()
   $txtDETAILS.CLEAR()
   $CLEAR_HANDLES_ARRAY = SPLIT($CLEAR_HANDLES,";")
   FOR EACH $ELEMENT IN $CLEAR_HANDLES_ARRAY
      $ = EXECUTE("$$CLIENT$ELEMENT = 'NOTHING'")
   NEXT
   $CLEAR_HANDLES = ""
   $SOCKETS = ""   ;Reintialize the SOCKETS collection
   $SOCKETS = $SYSTEM.COLLECTION()
ENDFUNCTION

FUNCTION tlbSTART_ONCLICK()
   $LISTENER         = $SYSTEM.SOCKET()
   $LISTENER.BLOCKING      = 0
   $LISTENER.ADDRESS      = $LOCALIP
   $LISTENER.ONACCEPT      = "evtACCEPT()"
   $LISTENER.PORT         = $PORT
   $LISTENER.BIND()
   $LISTENER.LISTEN
   $stsBAR.TEXT = "Listening: " + $LOCALIP + " : " + $PORT + @CRLF
   ;$FORM.ICON = @SCRIPTDIR + "\RUNNING.ICO"
ENDFUNCTION

FUNCTION tlbSTOP_ONCLICK()
   $LISTENER = ""
   $stsBAR.TEXT = "Stopped: " + $LOCALIP + " : " + $PORT + @CRLF
   ;$FORM.ICON = @SCRIPTDIR + "\STOPPED.ICO"
ENDFUNCTION

FUNCTION FORMAT_IP($IP)
   $FORMAT_IP = TRIM(SUBSTR($IP,1,3)) + "." + TRIM(SUBSTR($IP,5,3)) + "." + TRIM(SUBSTR($IP,9,3)) + "." + TRIM(SUBSTR($IP,13,3))
ENDFUNCTION


And once again, sorry for the CAPS. Wink

_________________
-Ben
Back to top
View user's profile Send private message
Bonji
KiXforms Aficionado
KiXforms Aficionado


Joined: 10 Mar 2003
Posts: 393
Location: Virginia

PostPosted: Sat Aug 07, 2004 1:48 am    Post subject: Reply with quote

lol

I used your KIM script and it did indeed have a hissy fit when using the telnet client. It appears that your script is a little too integrated with itself to work with external clients.

_________________
-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: Sat Aug 07, 2004 1:57 am    Post subject: Reply with quote

Hey Ben, check this out

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemnetsocketssocketclassselecttopic.asp

its dot-netty stuff ... interesting thing, check-out the methods on the left side - instead of having a Blocking mode, they have two sets of API's

BeginConnect ( starts a non-blocking connect)

Connect ( does a blocking connect)

hmmm interesting - what you think ?
Back to top
View user's profile Send private message
Bonji
KiXforms Aficionado
KiXforms Aficionado


Joined: 10 Mar 2003
Posts: 393
Location: Virginia

PostPosted: Sat Aug 07, 2004 2:10 am    Post subject: Reply with quote

Yeah, that is really good stuff. I like the two methods to determine the blocking method. It is a lot more clear as to which method is being used.
I'll keep checking out that link.

_________________
-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: Sat Aug 07, 2004 2:39 am    Post subject: Reply with quote

hmmm, not sure if this stuff would work well with Kixtart/Kixforms ... this before/after stuff uses app callbacks which would be impossible to implement with kixtart. Think though, I will use this dotnet model - it looks pretty darn good.
Back to top
View user's profile Send private message
Bonji
KiXforms Aficionado
KiXforms Aficionado


Joined: 10 Mar 2003
Posts: 393
Location: Virginia

PostPosted: Sat Aug 07, 2004 2:48 am    Post subject: Reply with quote

Just a reminder that .address and .port always returns "127.0.0.1" and "0" respectively.
_________________
-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: Sat Aug 07, 2004 3:11 am    Post subject: Reply with quote

ja, the next thing i'm working on is to break-out the address and port properties into Local and Remote addresses/ports. Getting some wierd results so far though - for some reason, when I query the local port on a listener, I get back some other number than 777 - is this normal ?
Back to top
View user's profile Send private message
Bonji
KiXforms Aficionado
KiXforms Aficionado


Joined: 10 Mar 2003
Posts: 393
Location: Virginia

PostPosted: Sat Aug 07, 2004 4:30 am    Post subject: Reply with quote

I can query the port property on the listener and it returns 777 (which is the first time the .port property returned something other than 0 for me).

If you are getting unexpected results, then I would make sure no kix process are still running behind the scenes using up that port. That happens a lot to me when I'm working on this stuff. I'll create a process and the GUI may go away (and I think it's finished), but the process is still running and locking out that port. It makes it frustrating sometimes when you don't realize that and spend 30+ minutes trying to figure out what is wrong.

Other than that, I can't think of a reason why the listener would return a port # other than what was specified for it.

_________________
-Ben
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 Previous  1, 2, 3, 4  Next
Page 3 of 4

 
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