Apple Newton Internet Enabler Spezifikationen Seite 5

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 24
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 4
Newton Technology Journal June 1996
5
if err then begin
print("link failed"); // handle the error
:endGrabLink(err); // end connect attempt
end
else // status.linkStatus = 'connected, so resolve name
DNSGetAddressFromName(“apple.com”, self, 'DNSCallback);
end;
The first statement, myLinkID:=linkID, saves the ID of the link
that InetGrabLink is in the process of grabbing in one of your
variables. You might want to store the link ID for use in other portions of
your application.
If grabbing of the link is progressing without errors, your callback
function gets called to report the progress. You can call the
InetDisplayStatus function, as shown in the above example. The
myStatView view used in the this example was created before the
grab of the link was initiated.
The grab of the link terminates when the connection is made or when an
error occurs. In either case, you can remove the status display view at that
point. To do so, call the InetDisplayStatus function with nil as
the value of the status parameter.
If InetGrabLink encounters an error, the error code will be a non-
zero value and your application has to do something with that error. In the
example function, a message is displayed and the connection attempt is
terminated.
If InetGrabLink succeeds, the callback receives 'connected
as the value of linkStatus. At that point, you can perform any
operations that are appropriate. The example function takes this
opportunity to convert its remote echo host name into an IP address, which
is saved in a local variable by the DNSCallback function.
Retrieving and Displaying Link Status Information
Many applications want to display status to the user while a net
connection is being established. Newton Internet Enabler makes this easy
for you with the InetDisplayStatus function, which displays link
status information on the Newton screen. Here is the declaration of the
function:
statusView InetDisplayStatus(linkID, statusView, status)
You can use the InetDisplayStatus function in three ways, as
follows:
to create a new status view, pass nil as the value of each parameter:
myStatusView := InetDisplayStatus(nil, nil, nil);
to display status for a link in an existing status view, pass in the link ID,
the status view, and the status frame that was sent to your callback
function:
InetDisplayStatus(myLinkID, myStatusView, myStatus);
to remove and dispose of the status view, pass nil as the value of the
status frame:
InetDisplayStatus(myLinkID, myStatusView, nil);
The InetStatusDisplay function creates and uses a view that is
based on protoStatusTemplate. For information about this
proto, see the chapter “Additional System Services” in Newton
Programmer’s Guide.
To initiate the status display, you need to open the status view. The most
convenient place to do this is just before your call to the
InetGrabLink function. For example, the following function creates
the status view, stores it in myStatView for subsequent use, and then
calls the InetGrabLink function:
DoGrabLink := func()
begin
myStatView := InetDisplayStatus(nil, nil, nil);
InetGrabLink(nil, self, 'GrabLinkCallback);
end;
While the grab operation is in progress, you can update the status display
whenever your callback function gets called. For example, the following
code segment from a grab link callback function updates the status display if
no errors have occurred and if the link status has not yet become
'connected
:
if err = nil and status.linkStatus <> 'connected then
InetDisplayStatus(linkID, myStatView, stat);
When the grab operation is done, you can remove the status display.
The following code segment from a grab link callback function removes the
status display when the link status becomes '
connected
:
if err = nil and status.linkStatus = 'connected then
InetDisplayStatus(linkID, myStatView, nil);
The view displayed by the InetDisplayStatus function contains
a button that the user can tap to call the InetCancelLink function,
which cancels the grab operation that is currently in progress.
Configuring Newton Internet Enabler for Your Endpoint
After grabbing your Newton Internet Enabler link, you need to instantiate
your endpoint. You send the Instantiate message to your endpoint
with the options required to configure Newton Internet Enabler for your
application.
You must set three options in your Instantiate message:
The 'inet service identifier option, which tells the Newton system
software to use Newton Internet Enabler with your endpoint.
The Inet tool physical link ('ilid') option, which tells Newton Internet
Enabler which link ID to use for your endpoint. Use the link ID that was
returned by the InetGrabLink function.
The Inet tool transport service type ('itsv' ) option, which tells Newton
Internet Enabler which transport type (for example, UDP or TCP) to use
for your endpoint.
Binding Your Endpoint with Newton Internet Enabler
After you instantiate your endpoint, you need to bind it to an address.
You either bind your endpoint to connect (initiate an outgoing connection),
or to listen for an incoming connection. If you are binding an endpoint that
is going to listen, you always need to pass the Inet local port ('ilpt') option
when you send the Bind message to your endpoint. If you are binding an
endpoint that is going to connect, you need to pass the Inet local port
option for UDP links, but not for TCP links.
The Inet local port option has two data slots that you specify: a short
value, InetPortNumber, and a Boolean value,
useDefaultPort. The useDefaultPort value only applies
when you are binding an endpoint to connect over a UDP link. Assign the
Seitenansicht 4
1 2 3 4 5 6 7 8 9 10 ... 23 24

Kommentare zu diesen Handbüchern

Keine Kommentare