[SparForte][Banner]
[Top Main Menu] Intro | Tutorials | Reference | Packages | Examples | Contributors   [Back Page]      [Next Page]  

TCP/IP Sockets

Network sockets can be declared using socket_type variables. Most of the file I/O functions will work with sockets as well as files.

The main difference between a socket and a file is that sockets are always "in" and "out". When opening a socket, do not specify a mode.

The name of the socket is a string containing the name of the server computer, followed by a colon and a port number. The port number is 80 (a web server) if no port is specified. Certain ports, such as those above 32767, are prohibited as a security precaution.

#!/usr/local/bin/bush
 
-- download a web page
 
f : socket_type;
c : character;
 
open( f, "www.somewebserver.com" );

put( f, "GET /index.html HTTP/1.0" & ASCII.CR & ASCII.LF
);
put( f, "User-Agent: SparForteTest/1.0 (SparForteTest)" & ASCII.CR &
ASCII.LF );
put( f, ASCII.CR & ASCII.LF );
 
loop
  get( f, c );
  put( c );
  exit when end_of_file( f );
end loop;
 
put_line( "End of web page" );
close( f );

 

Example: Hello World
[Right Submenu]

 AdaScript versus GCC

 Case Sensitivity

 Reserved Words

 Comments

 Literals

 Bourne Shell Word Expansions

 Fundamental Types

 User-defined Types

 Enumerated Types

 Arrays

 Records

 Basic Assignment

 The @ and % Operands

 Command Argument Shortcuts

 Redirection and Pipelines

 Command Line Interaction

 Built-in Shell Commands

 The Current Directory

 Database Commands

 Flow of Control

 Other Statements/ Subprograms

 External Commands

 Block Statements and Subprograms

 TCP/IP Sockets

 Numeric Formatting with Put

 Interpreter Directives

 Command Line Options

 Command Reference

 ASCII and Latin_1 Character Sets

 Common Error Messages

 Common PHP Functions and the SparForte Equivalent

[Back to Top] Back To Top [Small Forte Symbol]