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.


To list CNN's Web page:

IDL> sock_list,''

To capture a Web page into an array:

IDL> sock_list,'',page

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

To list a particular Web page:

IDL> sock_list,''

How to ping a server:

Use the procedure sock_ping.


To ping CNN:

IDL> sock_ping,'',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.


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

IDL> files=sock_find('','*.fts',path='/data/synoptic/mdi')

IDL> help,files

FILES           STRING    = Array[213]

IDL> print,files[0:4]

How to copy a file from a Web server:

Use the procedure sock_copy.


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

IDL> sock_copy,'',/verb

How to copy a file from an FTP server:

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


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

IDL> sock_copy,'',/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.


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

IDL> file=''

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.


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

IDL> command=''

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.


IDL> rfile=''
IDL> rsize=sock_size(rfile)
IDL> print,rsize

Last Revised: