SandelPerieanu Posted January 23, 2008 Share Posted January 23, 2008 (edited) oswinsck_vbscript.vbs 'http://www.ostrosoft.com/oswinsck.asp Dim oWinsock Dim sBuffer Dim sSource Dim bClose sBuffer = "": sSource = "": bClose = False Set oWinsock = CreateObject("OSWINSCK.Winsock") WScript.ConnectObject oWinsock, "oWinsock_" oWinsock.Connect "129.6.15.28", 13 Sub oWinsock_OnClose() oWinsock.CloseWinsock WScript.Echo sSource bClose = True Set oWinsock = Nothing End Sub Sub oWinsock_OnDataArrival(byVal Total) oWinsock.GetData sBuffer sSource = sSource & sBuffer End Sub While Not bClose WScript.Sleep 1 Wend this work! but Dim $owinsock = '' Dim $sbuffer = '' Dim $ssource = '' Dim $bclose = False $owinsock = ObjCreate("OSWINSCK.Winsock") ObjEvent($owinsock, "oWinsock_") $owinsock.Connect("129.6.15.28", 13) Func oWinsock_OnDataArrival($total) $owinsock.GetData($sbuffer) $ssource &= $sbuffer EndFunc While Not $bclose Sleep(1) Wend Func oWinsock_OnClose() $owinsock.CloseWinsock() MsgBox(262144, '', $ssource) $bclose = True $owinsock = 0 EndFunc don't work help! thanks! Edited January 23, 2008 by psandu.ro Link to comment Share on other sites More sharing options...
Squirrely1 Posted January 26, 2008 Share Posted January 26, 2008 (edited) psandu.ro - Here is my rewrite of your code, but it won't work yet. In place of the line that reads this way:;WScript.ConnectObject $oWinsock, "$oWinsock_"I think you need to create a WScript object on one line:$WScriptOBJ = ObjCreate("[insert Object Here]");perhaps "WScript.WScript.1"and then use this on the next line:$WScriptOBJ.ConnectObject($oWinsock, "oWinsock_")Global $oWinsock Global $sBuffer Global $sSource Global $bClose $sBuffer = "" $sSource = "" $bClose = False $oWinsock = ObjCreate("OSWINSCK.Winsock") ;WScript.ConnectObject $oWinsock, "$oWinsock_" $oWinsock.Connect("129.6.15.28", 13) While Not $bClose Sleep(36) Wend Func oWinsock_OnClose() $oWinsock.CloseWinsock MsgBox(0, "", $sSource) $bClose = True $oWinsock = "" EndFunc Func oWinsock_OnDataArrival($total) $sBuffer = $oWinsock.GetData($sBuffer) $sSource &= $sBuffer EndFuncAlso, I can't see where $total is ever used or where the functions are ever called, so you could do without them, based on the given code.Edit 1:One of the techie-spirits just wispered to me, "Cscript", so I thought about it and the following line:;WScript.ConnectObject $oWinsock, "$oWinsock_"which we can't use maybe can be replaced with this:Run("Cscript.ConnectObject " & $oWinsock & ", " & "oWinsock_", "", @SW_HIDE) Edited January 27, 2008 by Squirrely1 Das Häschen benutzt Radar Link to comment Share on other sites More sharing options...
DaleHohm Posted January 27, 2008 Share Posted January 27, 2008 Your rewrite looks good except I believe instead of anything along this line: ;WScript.ConnectObject $oWinsock, "$oWinsock_" instead you need $oEvt = ObjEvent($oWinsock, "oWinsock_") This sets up the event processing function prefix and allows things like oWinsock_OnClose() to be called when the onClose event fires. Dale Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model Automate input type=file (Related) Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded Better Better? IE.au3 issues with Vista - Workarounds SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead? Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble Link to comment Share on other sites More sharing options...
Squirrely1 Posted January 27, 2008 Share Posted January 27, 2008 Your rewrite looks good except I believe instead of anything along this line: ;WScript.ConnectObject $oWinsock, "$oWinsock_" instead you need $oEvt = ObjEvent($oWinsock, "oWinsock_") This sets up the event processing function prefix and allows things like oWinsock_OnClose() to be called when the onClose event fires. Dale So I guess this is the code we are recommending to psandu.ro so far: Global $oWinsock Global $sBuffer Global $sSource Global $bClose $sBuffer = "" $sSource = "" $bClose = False $oWinsock = ObjCreate("OSWINSCK.Winsock") $oEvt = ObjEvent($oWinsock, "oWinsock_") $oWinsock.Connect("129.6.15.28", 13) While Not $bClose Sleep(36) Wend Func oWinsock_OnClose() $oWinsock.CloseWinsock MsgBox(0, "", $sSource) $bClose = True $oWinsock = "" EndFunc Func oWinsock_OnDataArrival($total) $sBuffer = $oWinsock.GetData($sBuffer) $sSource &= $sBuffer EndFunc Well, I can't tell anyone why it would work or why those functions would be called - I don't know much about networking. And I doubt that I could test this code, so I won't even try, except upon recommendation from an anthropod or some higher form of life. Das Häschen benutzt Radar Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now