[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Socket!




landsman@my-deja.com writes:

> Has anyone tried to use the Unix/Windows SOCKET procedure in IDL V5.4,
> or thought about ways that it might be useful?     It looks to me like
> it should allow one to read a file on an anonymous FTP server, but I
> haven't figured out the syntax for this.   (I have no previous socket
> programming  experience in other languages, so I am proceeding
> naively...)
> 
> For example, I can open a socket to an anonymous FTP account on a
> machine named 'ftpservername'
> 
> IDL> socket, 1, 'ftpservername', 'ftp'
> 
> and read the welcome message
> 
> IDL> text = ''
> IDL> readf,1,text & print,text
> 
> but I haven't figured out the syntax for reading a file on
> the FTP server.    I'd also be interested in hearing of other possible
> applications  for the SOCKET procedure.    Is it mainly for use with a C
> interface, or is it useful in pure IDL applications?

FTP is a particularly unsuitable protocol because it requires a
*separate* connection for data exchange.  The socket you opened is
simply the control connection.  It may be very difficult to implement
this particular protocol in IDL since it requires the client, you, to
"listen" on the data socket, and I am not sure that SOCKET supports
that.

>From my chance to play with SOCKET, the telnet protocol does seem to
be implemented, so users are spared from doing the complicated and
arcane telnet negotiation.  If you want something FTP-like you might
try HTTP or TFTP (the "trival" FTP protocol).  Anyway you cut it, you
will probably need to implement the raw protocol.

I think Ron is right, SOCKET is a great opportunity for users to do
their own interprocess communication, but if you need some of the
standard protocols then seek outside library help.  Also, it should be
fairly easy to implement the HTTP protocol.  Try this to get yourself
started:

socket, unit, 'cow.physics.wisc.edu', 80, /get_lun
printf, unit, 'GET http://cow.physics.wisc.edu/~craigm/idl/idl.html'
text = ''
while eof(unit) EQ 0 do begin
  readf, unit, text
  print, text
endwhile
free_lun, unit

Happy socketing,
Craig

-- 
--------------------------------------------------------------------------
Craig B. Markwardt, Ph.D.         EMAIL:    craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
--------------------------------------------------------------------------