winsock.GetData problem 
Author Message
 winsock.GetData problem

hi, I'm trying to comunicate with a web server via MSWinsock control with
code like this:

var socket = WScript.CreateObject("MSWinsock.Winsock", "wsock_");
socket.RemoteHost = "127.0.0.1";
socket.RemotePort = 80;
socket.Connect();

while( (socket.State != sckError) && (socket.State != sckConnected) )
 WScript.Sleep( 20 );

if( socket.State == sckConnected )
 socket.SendData( "HEAD / HTTP/1.1\n\n" );

while( (socket.State != sckError) && (socket.State == sckConnected) )
 WScript.Sleep( 1000 );

function wsock_DataArrival( p_lTotalBytes )
{
 socket.GetData( strData );
 WScript.StdOut.WriteLine("data: " + strData + " " + p_lTotalBytes );
 socket.Close();

Quote:
}

...but strData never get the data.
is imposible?


Sat, 26 Nov 2005 06:55:45 GMT  
 winsock.GetData problem
Your equivalent in .vbs is as follows and was tested on my NT2K.  I
know the GetData requires an extra parameter but I couldn't ever get
it to work in any .js which only gave me the socketlength and never
socketdata.  All my socket scripts so far are in .vbs.

BitsNotBytes

Sub wsck_DataArrival(socketlength)
wsck.GetData socketdata, vbString
wscript.echo socketlength
wscript.echo socketdata
End Sub
Dim socketdata
Set wsck     = WScript.CreateObject("MSWinsock.Winsock","wsck_")
wsck.RemoteHost="www.google.com"
wsck.RemotePort=80
wsck.Protocol=0
wsck.Connect
do 'wait for connection
wscript.sleep 100
loop until wsck.state = 7
wsck.Senddata "HEAD / HTTP /1.1" & vbcrlf &vbcrlf
wscript.sleep 2000
wsck.Close
set wsck = nothing

Quote:

> hi, I'm trying to comunicate with a web server via MSWinsock control with
> code like this:

> var socket = WScript.CreateObject("MSWinsock.Winsock", "wsock_");
> socket.RemoteHost = "127.0.0.1";
> socket.RemotePort = 80;
> socket.Connect();

> while( (socket.State != sckError) && (socket.State != sckConnected) )
>  WScript.Sleep( 20 );

> if( socket.State == sckConnected )
>  socket.SendData( "HEAD / HTTP/1.1\n\n" );

> while( (socket.State != sckError) && (socket.State == sckConnected) )
>  WScript.Sleep( 1000 );

> function wsock_DataArrival( p_lTotalBytes )
> {
>  socket.GetData( strData );
>  WScript.StdOut.WriteLine("data: " + strData + " " + p_lTotalBytes );
>  socket.Close();
> }

> ...but strData never get the data.
> is imposible?



Sun, 27 Nov 2005 03:50:23 GMT  
 winsock.GetData problem
am 10.06.03 00:55 sprach Gabriel dieses:

Quote:
> hi, I'm trying to comunicate with a web server via MSWinsock control with
> code like this:

You could check the error-event and the BytesReceived-Prop.
At least this could give you a hint telling what's wrong:

Quote:
> function wsock_DataArrival( p_lTotalBytes )
> {
>  socket.GetData( strData );
>  WScript.StdOut.WriteLine("data: " + strData + " " + p_lTotalBytes

                   " " + socket.BytesReceived);
  );

Quote:
>  socket.Close();
> }

> ...but strData never get the data.
> is imposible?

function wsock_Error(i_errNum, psz_Descript, l_sCode,
                      sz_Source, sz_HelpFile,
                      l_HelpContext, b_CancelDisplay)
{
   WScript.Echo(
      i_errNum, psz_Descript, l_sCode, sz_Source,
      sz_HelpFile, l_HelpContext, b_CancelDisplay);

Quote:
}

gruss/regards,
Christoph


Sun, 27 Nov 2005 04:51:33 GMT  
 winsock.GetData problem
After some more research in the NG, the GetData parameter requires the
second parameter.  Unfortunately it is passed by reference and JSCRIPT
only passes by value.  VBScript can pass by reference so damn Bill
Gates and his language of preference ;-).

BitsNotBytes

Quote:

> Your equivalent in .vbs is as follows and was tested on my NT2K.  I
> know the GetData requires an extra parameter but I couldn't ever get
> it to work in any .js which only gave me the socketlength and never
> socketdata.  All my socket scripts so far are in .vbs.

> BitsNotBytes

> > function wsock_DataArrival( p_lTotalBytes )
> > {
> >  socket.GetData( strData );
> >  WScript.StdOut.WriteLine("data: " + strData + " " + p_lTotalBytes );
> >  socket.Close();
> > }

> > ...but strData never get the data.
> > is imposible?



Sun, 27 Nov 2005 19:14:18 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. GetData using MSWinsock.Winsock

2. Using MSWinsock.Winsock's GetData method from JScript?

3. Accessing MSChart DataGrid.GetData function from client-side VBScript

4. Accessing MSChart DataGrid.GetData function from client-side VBScript

5. Retreiving data from Java server through WinSock COM object

6. simple chat winsock+wscript.run(rundll)

7. SECURE Connection with Winsock or WinInet ?

8. THE RIGHT WINSOCK VERSION???

9. TCP/IP / Winsock...

10. Calls to winsock from jscript

11. POP3 Question w/Winsock

12. winsock.dll Object

 

 
Powered by phpBB® Forum Software