Plain Text
Global Const $SCKTCPPROTOCOL = 0 Global Const $SCKUDPPROTOCOL = 0x01 Global Const $SCKCLOSED = 0 Global Const $SCKOPEN = 0x01 Global Const $SCKLISTENING = 0x02 Global Const $SCKCONNECTIONPENDING = 0x03 Global Const $SCKRESOLVINGHOST = 0x04 Global Const $SCKHOSTRESOLVED = 0x05 Global Const $SCKCONNECTING = 0x06 Global Const $SCKCONNECTED = 0x07 Global Const $SCKCLOSING = 0x08 Global Const $SCKERROR = 0x09 Func ConnectTCP($sAddr, $iPort, $iTimeout) Local $oSocket, $timer $oSocket = ObjCreate("MSWinsock.Winsock") $oSocket.Protocol = $SCKTCPPROTOCOL ; set protocol to be tcp $timer = TimerInit() $oSocket.Connect($sAddr, $iPort) While 1 If $oSocket.State = $SCKERROR Then $oSocket = 0 Return -2 ;connection error (will give up for now) EndIf If $oSocket.State = $SCKCONNECTED Then $oSocket.Close $oSocket = 0 Return 0 ;Return $oSocket ; return object for connection EndIf If TimerDiff($timer) > $iTimeout Then $oSocket.Close $oSocket = 0 Return -3 ; connection timeout EndIf WEnd EndFunc ;==>Connect
After running that I get this:
I see MSWINSCK.OCX in my system32. (It has been unregistered and registered, still did nothing)==> Variable must be of type "Object".:
$oSocket.Protocol = $SCKTCPPROTOCOL
$oSocket^ ERROR
Do I have to install some special MSWinsock thing? Am I missing something?
I hope you can reply.
Edited by Glyph, 12 September 2009 - 06:12 AM.




