Apple Newton Internet Enabler Especificaciones Pagina 6

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 24
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 5
June 1996 Newton Technology Journal
6
InetPortNumber
a value as shown in Table 1-1 when sending the local
port option with a Bind request:
Table 1-1: Local port numbers for binding with Newton Internet Enabler
Bind type Transport service type Local port number
For connect TCP The system always selects the local port number, so
don’t set this option. You can, however, send a get
(opGetCurrent) of this option with your
Bind to retrieve the port number that the system
assigned.
For connect UDP If you specify true for useDefaultPort,
Newton Internet Enabler will select the local port to
use and will return its value in the option.
If you specify nil for useDefaultPort, you
must supply a port number that is not in use or the
Bind will fail.
For listen TCP Specify a port number to listen on as defined by the
IETF RFC 1700: Assigned Numbers ( October, 1994)
document.
For listen UDP Specify a port number to listen on as defined by the
IETF RFC 1700: Assigned Numbers document.
Connecting Your Endpoint with Newton Internet Enabler
After instantiating and binding your endpoint, you need to connect it. If
you are using a TCP link, you need to pass the TCP remote socket ('itrs')
option when you send the Connect message to your endpoint. This
option sets the host address with which TCP connects. You can use the
domain name server to get this address.
If you are using a UDP link, you do not need to pass any options in your
Connect message.
If you are using your endpoint to listen for an incoming connection, you
do not need to send any options with the Listen message.
Sending Data
You use Newton Internet Enabler to send data just as you would with any
Newton communications tool. You can set up an output specification frame
and send the Output message to your endpoint after you have
established a connection.
For UDP connections, you need to include the Inet UDP destination
socket ('iuds') option to establish the destination of the UDP datagram.
Your UDP output specification must include two flags in the sendFlags
slot: the kPacket and kEOP flags. For example, the following code
segment sends the string “Hello World!” out over a UDP link.
local myUDPstreamOutputSpec := {
form: 'string,
sendFlags: 'kPacket+'kEOP,
}
local myUDPOptions :=
[{
label: "iuds",
type: 'option,
opCode: opSetCurrent,
result: nil,
form: 'template,
data:
{
arglist:
[
130, // byte 1 of host address
43, // byte 2 of host address
2, // byte 3 of host address
2, // byte 4 of host address
7, // destination port number
],
typelist:
[
'struct,
'byte,
'byte,
'byte,
'byte,
'short
]
}
}];
try
ep:Output("Hello World!", myUDPOptions,
myUDPstreamOutputSpec);
onexception |evt.ex.comm| do
return :DoDisconnect();
For TCP links, you do not need to include any options in your Output
message, nor do you need to specify any sendFlags values in the
output specification frame. For example, the following code segment sends
the string “Hello World!” out over a TCP link.
local myTCPstreamOutputSpec := {
form: 'string,
}
try
ep:Output("Hello World!", nil, myTCPstreamOutputSpec);
onexception |evt.ex.comm| do
return :DoDisconnect();
The above example calls the application’s DoDisconnect function
if any communication exception occurs while sending the data.
You can also send expedited data over a TCP link. Expedited data is a
single byte of data that gets sent immediately. The data byte gets inserted in
front of any data on the remote end that has been received but not yet
processed. For example, you might need to send out a break character in
the middle of transmitting a large amount of data. To do so, you use the Inet
expedited data option with your Output message.
See the chapter “Endpoint Interface” in Newton Programmer’s Guide for
detailed information about output specification frames and the Output method.
Receiving Data
You use Newton Internet Enabler to receive data just as you would with
any Newton communications tool. Typically, this means that you set up an
input specification frame and send the SetInputSpec message to
your endpoint.
For UDP links, your input specification frame must include the
kPacket receive flag and must include useEOP:true in the
termination slot. In addition, you can include two options in the
rcvOptions slot if you want to: include the UDP source socket option
to retrieve the address of the datagram sender, and include the UDP
destination socket option if you want to retrieve the exact address to which
the packet you received was sent. The destination address might be other
than your local address if the packet was sent to a broadcast address.
The following code segment receives a datagram packet over a UDP link.
local streamInputSpec := {
form: 'string,
termination: {useEOP: true},
discardAfter: 256,
rcvFlags: kPacket,
rcvOptions: {
label: "iuss",
Vista de pagina 5
1 2 3 4 5 6 7 8 9 10 11 ... 23 24

Comentarios a estos manuales

Sin comentarios