|
Class: SocketHandle (private in UnixOperatingSystem
This class is only visible from within
UnixOperatingSystem.
Object
|
+--ExternalAddress
|
+--OSHandle
|
+--OSFileHandle
|
+--UnixOperatingSystem::FilePointerHandle
|
+--UnixOperatingSystem::SocketHandle
- Package:
- stx:libbasic
- Category:
- OS-Unix
- Owner:
- UnixOperatingSystem
constants
-
protocolCodeOf: aNameOrNumber
-
convert a symbol to a numeric protocol code
Usage example(s):
self protocolCodeOf:#tcp
self protocolCodeOf:#udp
self protocolCodeOf:#raw
|
-
protocolSymbolOf: anInteger
-
convert a numeric protocol code to a symbol
Usage example(s):
self protocolSymbolOf:(self protocolCodeOf:#tcp)
self protocolSymbolOf:(self protocolCodeOf:#udp)
self protocolSymbolOf:(self protocolCodeOf:#icmp)
|
initialization
-
reinitialize
-
clear the protocol cache, when the system has been restarted
queries
-
getAddressInfo: hostName serviceName: serviceName domain: domainArg type: typeArg protocol: protoArg flags: flags
-
answer an Array of socket addresses for serviceName on hostName.
A nil hostName will return the loopback address(es) e.g. localhost.
Domain, type, protocol may be nil or specify a hint for the socket
addresses to be returned.
The sorting function used within getaddrinfo() is defined in RFC 3484;
in linux the order can be
tweaked for a particular system by editing /etc/gai.conf
Usage example(s):
self getAddressInfo:'localhost' serviceName:nil
domain:nil type:nil protocol:nil flags:nil
self getAddressInfo:nil serviceName:22
domain:nil type:nil protocol:nil flags:nil
self getAddressInfo:'' serviceName:22
domain:nil type:nil protocol:nil flags:nil
self getAddressInfo:'localhost' serviceName:nil
domain:nil type:#stream protocol:nil flags:nil
self getAddressInfo:'localhost' serviceName:nil
domain:#inet type:#stream protocol:#tcp flags:nil
self getAddressInfo:'blurb.exept.de' serviceName:nil
domain:#inet type:nil protocol:nil flags:nil
self getAddressInfo:'1.2.3.4' serviceName:'bla'
domain:#inet type:nil protocol:nil flags:nil
self getAddressInfo:'2003:E2:EF32:D400:4C2C:DAEA:88FA:E300' serviceName:'echo'
domain:#inet6 type:nil protocol:nil flags:nil
self getAddressInfo:'localhost' serviceName:'echo'
domain:#inet type:nil protocol:nil flags:nil
self getAddressInfo:nil serviceName:'echo'
domain:#inet type:nil protocol:nil flags:nil
self getAddressInfo:nil serviceName:nil
domain:#inet type:nil protocol:nil flags:nil
self getAddressInfo:'www.google.de' serviceName:80
domain:nil type:nil protocol:nil flags:nil
self getAddressInfo:'www.exept.de' serviceName:nil
domain:nil type:nil protocol:nil flags:nil
self getAddressInfo:'www.exept.de' serviceName:'https'
domain:#'AF_INET' type:nil protocol:nil flags:nil
self getAddressInfo:'www.exept.de' serviceName:'https'
domain:#'AF_UNSPEC' type:nil protocol:nil flags:nil
self getAddressInfo:'www.exept.de' serviceName:nil
domain:#'AF_INET6' type:nil protocol:nil flags:nil
self getAddressInfo:'www.baden-württemberg.de' serviceName:nil
domain:#'AF_INET' type:#stream protocol:nil flags:nil
self getAddressInfo:'www.baden-württemberg.de' serviceName:nil
domain:#'AF_INET6' type:#stream protocol:nil flags:nil
self getAddressInfo:'www.google.com' serviceName:nil
domain:#'AF_INET' type:#stream protocol:nil flags:nil
self getAddressInfo:'www.google.com' serviceName:nil
domain:#'AF_INET6' type:#stream protocol:nil flags:nil
|
-
getNameInfo: socketAddress wantHostName: wantHostName wantServiceName: wantServiceName datagram: useDatagram flags: flags
-
answer an Array containing the hostName and serviceName
in socketAddress.
This is the generic version of getHostByAddr, however, if supported by the OS,
this returns multiple hostnames (if appropriate)
Usage example(s):
self getNameInfo:
(self getAddressInfo:'localhost' serviceName:'echo'
domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
wantHostName:true wantServiceName:true datagram:false flags:0
self getNameInfo:
(self getAddressInfo:'localhost' serviceName:'echo'
domain:#AF_UNSPEC type:#stream protocol:nil flags:nil) first socketAddress
wantHostName:true wantServiceName:true datagram:false flags:0
self getNameInfo:
(self getAddressInfo:'exept.de' serviceName:'echo'
domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
wantHostName:true wantServiceName:true datagram:false flags:0
self getNameInfo:
(self getAddressInfo:'exept.de' serviceName:'echo'
domain:#AF_UNSPEC type:#stream protocol:nil flags:nil) first socketAddress
wantHostName:true wantServiceName:true datagram:false flags:0
self getNameInfo:
(self getAddressInfo:'217.172.183.25' serviceName:'22'
domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
wantHostName:true wantServiceName:true datagram:false flags:0
self getNameInfo:
(self getAddressInfo:'1.2.3.4' serviceName:'22'
domain:#inet type:#stream protocol:nil flags:nil) first socketAddress
wantHostName:true wantServiceName:true datagram:false flags:0
|
-
primGetAddressInfo: hostName serviceName: serviceName domainCode: domain socketTypeCode: type protocolCode: proto flags: flags
-
answer an Array of socket addresses for serviceName on hostName
Domain, type, protocol may be nil or specify a hint for the socket
addresses to be returned.
A nil hostName resolves to the loopback interface address (localhost).
An empty hostname resolves to an address that may be used for a lisstening server.
accepting
-
acceptWithPeerAddressBuffer: peerOrNil
-
accept a connection on a server port.
Returns a new SocketHandle or nil if the operation
would block.
If peerOrNil is set to a ByteArray, the socket address
of the connection peer is stored into it.
binding
-
bindTo: socketAddress
-
low level bind -
Set the local address of the socket
Usage example(s):
(Socket domain:#inet type:#stream)
bindTo:(IPSocketAddress hostAddress:IPSocketAddress anyAddress port:9999)
reuseAddress:false ;
yourself
|
connecting
-
cancelConnect
-
cancel an asynchronous connect in progress
-
connectTo: socketAddress
-
low level connect; connect to a socket address.
Return true if connection has been established,
false, when the connection has been initiated but not yet
completed. If an error occurred, an OSError is raised
Usage example(s):
Socket newTCP connectTo:(IPSocketAddress hostAddress:IPSocketAddress local port:7)
withTimeout:nil.
Socket newTCP connectTo:(IPSocketAddress hostAddress:IPSocketAddress local port:5768)
withTimeout:nil.
Socket newTCP connectTo:(IPSocketAddress hostAddress:#[1 2 3 4] port:7)
withTimeout:nil.
|
datagram transmission
-
receiveFrom: socketAddress buffer: aDataBuffer start: startIndex for: nBytes flags: flags
-
receive datagramm data - put address of originating host into
anAddressBuffer, data into aBuffer. For ST-80 compatibility,
the addressBuffer may be a non-ByteArray; then, it must understand
the addressBytes-message (i.e. be a SocketAddress instance).
Return the number of bytes received, or a negative number on error.
The thread blocks until data arrives - you may want to wait before
receiving, using #readWait or #readWaitWithTimeout:.
-
sendTo: socketAddress buffer: aDataBuffer start: startIndex for: maxBytes flags: flags
-
send datagramm data - fetch address of destination host from
anAddressBuffer, data from aDataBuffer starting at startIndex,
sending count bytes.
SocketAddress must be an instance of SocketAddress
Return the number of bytes transmitted, or a negative number on error.
initialization
-
domain: domainArg type: typeArg protocol: protocolArg
-
set up socket with domain, type and protocol number.
This is a low level entry; no binding, listening or connect is done.
All arguments must be symbols from one of
domainArg: #AF_INET, #AF_UNIX, #AF_APPLETALK (#inet, #unix, #appletalk, #x25) ..
type: #SOCK_STREAM, #SOCK_DGRAM (#stream, #datagram, #raw) ..
protocol: #tcp, #udp, #raw ..
Usage example(s):
self new domain:#inet type:#stream protocol:nil
|
misc
-
getOptionsLevel: level name: name
-
answer a ByteArray containing the socket option value
named name at level
-
listenFor: aNumber
-
start listening.
aNumber is the number of connect indications queues
by the operating system
-
setOptionsLevel: level name: name value: value
-
set the socket option name at level to value.
Value may be one of SmallInteger, ByteArray or nil
-
shutdown: anInteger
-
inform the socket that no more I/O will happen.
anInteger == 0 no reads will be performed
anInteger == 1 no writes will be performed
anInteger == 2 neither reads nor writes will be performed.
Pending data is discarded. This is faster tha
close, which may wait until pending (written)
data has been read by the other side
queries
-
getNameInto: socketAddress
-
answer the my own address (I am bound to this address).
Note that this address may change after connect or accept.
-
getPeerInto: socketAddress
-
answer the my own address (I am bound to this address).
Note that this address may change after connect or accept.
|