Overview of the Sockets Package
List of Sockets Package Commands
use Sockets in ... end use
The Sockets package is a suite of tools for network communication in Maple. The commands in this package enable you to connect to processes on remote hosts on a network (such as an Intranet or the Internet) and exchange data with these processes. In particular, it enables two independent Maple processes running on different machines on a network to communicate with one another.
For important notes on network security, see the release notes for this package Sockets,release.
This package presents a user interface to reliable, connection-oriented, stream sockets in the Internet domain (TCP/IP). You can create a client socket by using procedure Sockets:-Open, which enables you to connect to and communicate with a server on a remote machine. You can also create a server socket by using procedure Sockets:-Serve, which enables you to offer computational services to which others can connect and make requests.
The Sockets package automatically shuts down any open connections that it is managing before being garbage collected, or when the Maple process in which it is running terminates normally. However, there is no user control over when this occurs (except in the case of termination), so you should not rely on it to shut down socket connections normally.
For more information about platform support and run-time issues, see Sockets release notes.
Each command in the Sockets package can be accessed by using either the long form or the short form of the command name in the command calling sequence.
The long form, Sockets:-command, is always available. The short form can be used after loading the package.
If you are using these routines for programming, you can access the exports of this package by enclosing your code in a use statement that binds this package; for example, use Sockets in ... end use. See use for more details.
All socket connections created by routines in this package are represented by an opaque type exported as Sockets:-socketID, which is local to the Sockets package. You can test whether an expression expr has the correct structure for a socket ID by using type( expr, Sockets:-socketID ). (Note that the type must not be quoted in this case.)
The following is a list of available commands.
To display the help page for a particular Sockets command, see Getting Help with a Command in a Package.
Use with to obtain interactive access to the package procedures.
Find out where you are on the network.
Open a connection to the echo server on the peer (a particular machine on the same network as the machine that generated this help page).
sid ≔ Open⁡mantis,echo
Send a message to the peer.
Write⁡sid,sprintf⁡Hello from %s!
Read back the response.
Hello from a7b390d1c58d!
Shut down the connection.
The following program finger enables you to make a query by using the finger protocol.
finger := proc( _who )
local who, at, host, sock;
who := _who;
at := StringTools:-FirstFromLeft( "@", who );
if at <> FAIL then
host := who[ 1 + at .. -1 ];
who := who[ 1 .. at - 1 ]
host := "localhost"
use Sockets in
sock := Open( host, finger );
Write( sock, sprintf( "%s\r\n", who ) );
printf( "%s\n", Read( sock, 5 ) );
Close( sock )
For background material on network programming concepts in the Sockets package, see references.
Sockets release notes
Download Help Document
What kind of issue would you like to report? (Optional)