No, I'm playing around with the low level winsock object.I can create a listener and telnet to it, but the socket state never changes from "listening". When the object hears my incoming telnet session it will trigger a "ConnectionRequest" event which passes a requestID.
While waiting the socket state should change to "ConnectionPending", but it doesn't. I guess that the inability to raise events is causing this, but I'm not sure. If I attempt to accept the connection anyway I get a "socket is not in the correct state" error.
I'm quite happy that the two are talking - as soon as I quit the listener the telnet session from the remote machine is also killed.
I'd write my own library which didn't depend on events, but I'm a *nix "C" coder and I get nervous at the sight of object orientation, and positively ill when confronted with non linear program control, so I'm struggling.
I've been looking at the idispatch stuff to see if I can find the events in a stack somewhere and handle them manually, but it has given me a headach so I'm going to have a lie-down.
Perhaps a facility to register Kix functions as handlers for events is the best way to go. Sounds like an awful lot of work though.
In case I'm missing something, here is a simple example of the code I was playing with:
code:
break on$oSocket = CreateObject("mswinsock.winsock")
if @error <> 0 "Cannot create socket object:" ? @error " / " @serror ? exit 1 endif
"My Name: " $oSocket.LocalHostName ? ; Who am i
"My IP: " $oSocket.LocalIP ? ; Where am i
$oSocket.Protocol=0 ; Equates to TCP
$oSocket.LocalPort=10000 ; Any old non-restricted socket
$oSocket.RemotePort=0 ; We are a listener
$oSocket.Listen ; Start Listening
if @error <> 0 @error " / " @serror ? endif
while $cKeyPress <> "q"
?
"Socket Information: " ?
" Status: " $oSocket.State ?
" RemoteHost: " $oSocket.RemoteHost ?
" RemoteHostIP: " $oSocket.RemoteHostIP ?
" RemotePort: " $oSocket.RemotePort ?
" BytesReceived: " $oSocket.BytesReceived ?
" SocketHandle: " $oSocket.SocketHandle ?
" Hit a key to refresh, 'q' to exit: " get $cKeyPress
loop
$oSocket=0
If you run the script (and have the winsock control!) you will start a listener on port 10000. You will see that the status is "2", which is sckListening. You can now telnet to port 10000. The status should change to "3", sckConnectionPending but it doesn't.
If you drop the listener (hit 'q') you will see that the telnet session is forced closed as well.
I'm a bit of a COM numpty, so any advice / direction would be appreciated.