Jump to content



Photo

Problem with MSWinsock.Winsock


  • Please log in to reply
2 replies to this topic

#1 Glyph

Glyph

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 807 posts

Posted 12 September 2009 - 06:09 AM

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:

==> Variable must be of type "Object".:
$oSocket.Protocol = $SCKTCPPROTOCOL
$oSocket^ ERROR

I see MSWINSCK.OCX in my system32. (It has been unregistered and registered, still did nothing)
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.








#2 Ptifou78

Ptifou78

    Seeker

  • Active Members
  • 11 posts

Posted 12 November 2010 - 09:08 AM

up?

#3 Richard Robertson

Richard Robertson

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 9,716 posts

Posted 12 November 2010 - 09:45 AM

Why not just use the built in network functions?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users