|
Class: PortMapperClient (in SunRPC)
Object
|
+--SunRPC::RPCEndPoint
|
+--SunRPC::RPCClient
|
+--SunRPC::PortMapperClient
- Package:
- stx:goodies/communication
- Category:
- Net-Communication-SunRPC
- Version:
- rev:
1.20
date: 2021/01/20 14:56:16
- user: cg
- file: SunRPC_RPCPortMapper.st directory: goodies/communication
- module: stx stc-classLibrary: communication
interface to the portmapper; see RFC1057 and examples.
copyrightCOPYRIGHT (c) 2002 by eXept Software AG
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
constants
-
PROTO_TCP
-
-
PROTO_UDP
-
-
knownProgramNumbers
-
spec
-
xdr
-
helpers
-
protocolNumberFor: symbolicOrNumericProtocol
-
operations
-
callit: call_args
-
-
dump
-
return a dump-list of the portmappers state.
roughly equivalent to 'rpcinfo -p' unix command
Usage example(s):
|mapper list|
mapper := self toHost:'localhost'.
list := mapper dump.
mapper close.
list inspect
|
-
getport: mapping
-
get the port for a (program version protocol) tuple
Usage example(s):
|mapperClient port arg|
mapperClient := self toHost:'alan'.
arg := Dictionary new
at:'prog' put:100000;
at:'vers' put:2;
at:'prot' put:#tcp;
at:'port' put:nil;
yourself.
port := mapperClient getport:arg.
mapperClient close.
port
|
-
set: mapping
-
register a port for a (program version protocol port) tuple
Usage example(s):
|mapperClient arg ok|
mapperClient := self toHost:'localhost'.
arg := Dictionary new
at:'prog' put:200000;
at:'vers' put:1;
at:'prot' put:#tcp;
at:'port' put:3333;
yourself.
ok := mapperClient set:arg.
mapperClient close.
ok
(self toHost:'localhost') dump; close
|
-
unset: mapping
-
unregister a port for a (program version protocol) tuple
Usage example(s):
|arg mapperClient ok|
mapperClient := (self toHost:'localhost').
arg := Dictionary new
at:'prog' put:200000;
at:'vers' put:1;
at:'prot' put:#tcp;
yourself.
ok := mapperClient unset:arg.
mapperClient close.
ok
(self toHost:'localhost') dump; close
|
operations - convenient interface
-
dumpAndShow
-
dump the portmapper information.
roughly equivalent to 'rpcinfo -p' unix command
Usage example(s):
(self toHost:'localhost') dumpAndShow; close
|
-
getportForProgram: programNr version: vsnNr protocol: prot
-
get the port for a (program version protocol) tuple.
prot must be one of #tcp or #udp
Usage example(s):
|mapperClient port|
mapperClient := self toHost:'alan'.
port := mapperClient getportForProgram:100000 version:2 protocol:#tcp.
mapperClient close.
port
|
-
setProgram: programNr version: vsnNr protocol: prot port: portNr
-
register a port for a (program version protocol) tuple
Usage example(s):
|mapperClient ok|
mapperClient := (self toHost:'localhost').
ok := mapperClient setProgram:200000 version:1 protocol:#tcp port:3333.
mapperClient close.
ok
(self toHost:'localhost') dump; close
|
-
unsetProgram: programNr version: vsnNr protocol: prot
-
unregister a port for a (program version protocol) tuple
Usage example(s):
|mapperClient ok|
mapperClient := (self toHost:'localhost').
ok := mapperClient unsetProgram:200000 version:1 protocol:#tcp.
mapperClient close.
ok
(self toHost:'localhost') dump; close
|
queries
-
portNumber
-
-
protocol
-
Notice: windows systems have no portMapper running -
you must try these on a unix box
(or change 'localhost' to the name of a box running a real OS in your network).
connect test:
|mapper|
mapper := SunRPC::PortMapperClient toHost:'localhost'.
mapper close.
|
|mapper|
mapper := SunRPC::PortMapperClient toHost:'exeptn' protocol:#udp port:111.
mapper close.
|
dump the current mapping (same as 'rpcinfo -p' command):
|mapper|
mapper := SunRPC::PortMapperClient toHost:'exeptn'.
mapper dumpAndShow.
mapper close.
|
dump the current mapping via udp (same as 'rpcinfo -p' command):
|mapper|
mapper := SunRPC::PortMapperClient toHost:'exeptn' protocol:#udp port:111.
mapper dumpAndShow.
mapper close.
|
dump the current mapping via tcp (same as 'rpcinfo -p' command):
|mapper|
mapper := SunRPC::PortMapperClient toHost:'exeptn' protocol:#tcp port:111.
mapper dumpAndShow.
mapper close.
|
get a mapping:
|mapper port|
mapper := SunRPC::PortMapperClient toHost:'localhost'.
port := mapper getportForProgram:100000 version:2 protocol:#tcp.
mapper close.
Transcript showCR:port.
|
set a port (please validate with 'rpcinfo -p'):
|mapper ok|
mapper := SunRPC::PortMapperClient toHost:'localhost'.
ok := mapper setProgram:200000 version:1 protocol:#tcp port:33333.
mapper close.
ok ifFalse:[self error]
|
unset a port (please validate with 'rpcinfo -p'):
|mapper ok|
mapper := SunRPC::PortMapperClient toHost:'localhost'.
ok := mapper unsetProgram:200000 version:1 protocol:#tcp.
mapper close.
ok ifFalse:[self error]
|
|