IDL Sockets Users Guide

D. M. Zarro (ADNET/GSFC)



The following IDL socket programs are supported on most systems running IDL versions greater than 5.3. They use the IDL class http to create TCP/IP sockets. The library modules required for this software are contained in ssw_ssw_gen.tar.Z .

Unless otherwise specified, the URL qualifier http:// is optional in the examples below.


How to list a file or Web page from a remote server:

Use the procedure sock_list to list a URL.

Examples

To list CNN's Web page:

IDL> sock_list,'http://www.cnn.com'

To capture a Web page into an array:

IDL> sock_list,'http://www.cnn.com',page

IDL> help,page
PAGE            STRING    = Array[876]

To list a particular Web page:

IDL> sock_list,'http://achilles.nascom.nasa.gov/~zarro/dmz.html'


How to ping a server:

Use the procedure sock_ping.

Example

To ping CNN:

IDL> sock_ping,'http://www.cnn.com',status,time=time
where status= 1 or 0 if the server is up or down. The response time (in seconds) is returned in the keyword time.


How to search for files on a Web server:

Use the function sock_find to search for file names or patterns.

Example

To list synoptic SOHO Michelson Doppler Imager (MDI) FITS files in the SOHO Synoptic data archive:

IDL> files=sock_find('http://sohowww.nascom.nasa.gov','*.fts',path='/data/synoptic/mdi')

IDL> help,files

FILES           STRING    = Array[213]

IDL> print,files[0:4]

http://sohowww.nascom.nasa.gov/data/synoptic/mdi/mdi_igram_fd_20010303_1912.fts.gz
http://sohowww.nascom.nasa.gov/data/synoptic/mdi/mdi_igram_fd_20010304_0312.fts.gz
http://sohowww.nascom.nasa.gov/data/synoptic/mdi/mdi_igram_fd_20010304_0936.fts.gz
http://sohowww.nascom.nasa.gov/data/synoptic/mdi/mdi_igram_fd_20010304_1736.fts.gz
http://sohowww.nascom.nasa.gov/data/synoptic/mdi/mdi_igram_fd_20010304_1912.fts.gz



How to copy a file from a Web server:

Use the procedure sock_copy.

Example

To copy an MDI FITS file from the SOHO Synoptic data archive:


IDL> sock_copy,'http://sohowww.nascom.nasa.gov/data/synoptic/mdi/mdi_igram_fd_20010303_1912.fts.gz',/verb


How to copy a file from an FTP server:

Use the procedure sock_copy, but include ftp:// in the URL.

Example

To copy a H-alpha FITS image file from the Big Bear Solar Observatory data archive:

IDL> sock_copy,'ftp://ftp.bbso.njit.edu/pub/archive/2006/11/10/kanz_halph_fr_20061110_085117.fts.gz',/verb


The above example assumes an anonymous FTP server that supports PASSIVE transfer mode.

How to read a FITS file from a Web server:

Use the procedure sock_fits.

Example

To read a synoptic H-alpha FITS file from the SOHO Synoptic data archive:

IDL> file='http://sohowww.nascom.nasa.gov/data/synoptic/kanz/kanz_halph_fd_19990102_1046.fts'

IDL> sock_fits,file,data,header=header

IDL> help,data,header
DATA            BYTE      = Array[1008, 1016]
HEADER          STRING    = Array[34]

Note that gzipped FITS files cannot be read directly from a Web server. In addition, FITS cannot be read from an FTP server. In these cases, use SOCK_COPY to first download the file.


How to send a CGI or PHP command to a Web server:

Use the procedure sock_list.

Example

To send a command to list a program (e.g. xdoc.pro) on the SSW server at the SDAC:

IDL> command='http://achilles.nascom.nasa.gov/~zarro/php/reformat.php?file=xdoc.pro'

IDL> sock_list,command,output

IDL> help,page
PAGE            STRING    = Array[88]


How to get the size (in bytes) of a remote file on a Web server:

Use the function sock_size.

Example


IDL> rfile='http://sohowww.nascom.nasa.gov/data/synoptic/mdi/mdi_igram_fd_20010303_1912.fts.gz'
IDL> rsize=sock_size(rfile)
IDL> print,rsize
     873324.


Last Revised: