Network-Protocols

FTPClient
A minimal FTP client program. Could store all state in inst vars, and use an instance to represent the full state of a connection in progress. But simpler to do all that in one method and have it be a complete transaction.
Always operates in passive mode (PASV). All connections are initiated from client in order to get through firewalls.
See ServerDirectory openFTP, ServerDirectory getFileNamed:, ServerDirectory putFile:named: for examples of use.
See TCP/IP, second edition, by Dr. Sidnie Feit, McGraw-Hill, 1997, Chapter 14, p311.
abortDataConnection
ascii
binary
changeDirectoryTo:
closeDataSocket
dataSocket
dataSocket:
defaultPortNumber
deleteDirectory:
deleteFileNamed:
get:dataInto:
Reel in data until the server closes the connection or the limit is reached.
At the same time, watch for errors on otherSocket.
getData
getDataInto:
Reel in all data until the server closes the connection. At the same time, watch for errors on otherSocket. Don't know how much is coming. Put the data on the stream.
getDirectory
getFileList
getFileNamed:
getFileNamed:into:
getPartial:fileNamed:into:
logFlag
login
loginUser:password:
lookForCode:ifDifferent:
We are expecting a certain numeric code next.
However, in the FTP protocol, multiple lines are allowed.
If the response is multi-line, the fourth character of the first line is a
$- and the last line repeats the numeric code but the code is followed by
a space. So it's possible that there are more lines left of the last response that
we need to throw away. We use peekForAll: so that we don't discard the
next response that is not a continuation line.
makeDirectory:
openDataSocket:port:
openPassiveDataConnection
passive
putFileNamed:as:
FTP a file to the server.
putFileStreamContents:as:
FTP a file to the server.
pwd
quit
rawResponseCodes
removeFileNamed:
renameFileNamed:to:
sendStreamContents:
HTTPSocket
HTTPSockets support HTTP requests, either directly or via an HTTP proxy server. An HTTPSocket saves the parse of the last ASCII header it saw, to avoid having to parse it repeatedly.
The real action is in httpGet:accept:. See the examples in the class, especially httpFileInNewChangeSet: and httpShowGif:.
addHTTPProxyPreferences
addProxyException:
argString:
argStringUnencoded:
blabEmail:
checkHTTPProxyPreferences
contentType
contentType:
extract the content type from the header. Content-type: text/plain<cr><lf>, User may look in headerTokens afterwards.
contentsLength:
extract the data length from the header. Content-length: 1234<cr><lf>, User may look in headerTokens afterwards.
defaultPort
digestFor:method:url:user:password:
digestFrom:method:url:user:password:
expandUrl:ip:port:
fetchExternalSettingsIn:
getHeader:
getHeader:default:
getResponseUpTo:
Keep reading until the marker is seen. Return three parts: header, marker, beginningOfData. Fails if no marker in first 2000 chars.
getResponseUpTo:ignoring:
Keep reading, until the marker is seen, skipping characters in ignoreString when
comparing to the marker. Return three parts: header, marker, beginningOfData.
Fails if no marker in first 2000 chars.
getRestOfBuffer:
We don't know the length. Keep going until connection is closed. Part of it has already been received. Response is of type text, not binary.
getRestOfBuffer:totalLength:
Reel in a string of a fixed length. Part of it has already been received. Close the connection after all chars are received. We do not strip out linefeed chars. tk 6/16/97 22:32
header:
set the headers. Then getHeader: can be used
httpFileIn:
httpFileInNewChangeSet:
httpGet:
httpGet:accept:
httpGet:args:accept:
httpGet:args:accept:request:
httpGet:args:user:passwd:
httpGetDocument:
httpGetDocument:accept:
httpGetDocument:args:
httpGetDocument:args:accept:
httpGetDocument:args:accept:request:
httpGetNoError:args:accept:
httpGif:
httpJpeg:
httpPost:args:accept:
httpPost:args:user:passwd:
httpPostDocument:args:
httpPostDocument:args:accept:
httpPostDocument:args:accept:request:
httpPostMultipart:args:accept:request:
httpPostToSuperSwiki:args:accept:request:
httpProxyExceptions
httpProxyPort
httpProxyPort:
httpProxyServer
httpProxyServer:
httpPut:to:user:passwd:
httpShowChunk:
httpShowGif:
httpShowJpeg:
httpShowPage:
initHTTPSocket:ifError:
initHTTPSocket:timeoutSecs:ifError:
initHTTPSocket:wait:ifError:
initialize
Subclasses should redefine this method to perform initializations on instance creation
md5Hash:
proxySettingsFileName
proxyTestingComment
proxyUser:password:
redirect
See if the header has a 'Location: url CrLf' in it. If so, return the new URL of this page. tk 6/24/97 18:03
removeProxyException:
responseCode
retry:asking:ifGiveUp:
shouldUseProxy:
showImage:named:
stopUsingProxyServer
useProxyServerNamed:port:
useProxyServerNamed:port:proxyUser:password:
userAgentString
LoginFailedException
Exception for signaling login failures of protocol clients.
isResumable
Resumable so we can give the user another chance to login
POP3Client
This class implements POP3 (Post Office Protocol 3) as specified in RFC 1939. (see http://www.ietf.org/rfc.html)
You can use it to download email from the mail server to your personal mail program.
To see an example of it's use, see POPSocket class>>example.
apopLogin
Attempt to authenticate ourselves to the server without sending the password as cleartext.
apopLoginUser:password:
clearTextLogin
defaultPortNumber
deleteMessage:
delete the numbered message
example
getMultilineResponse
Get a multiple line response to the last command, filtering out LF characters. A multiple line response ends with a line containing only a single period (.) character.
logFlag
login
loginMethod
loginMethod:
loginUser:password:
loginUser:password:loginMethod:
messageCount
Query the server and answer the number of messages that are in the user's mailbox.
quit
QUIT <CRLF>
responseIsError
responseIsWarning
retrieveMessage:
retrieve the numbered message
POP3LoginError
Exception for signaling POP3 login failures.
ProtocolClient
ProtocolClient is the abstract super class for a variety of network protocol clients.
It uses a stream rather than the direct network access so it could also work for streams on serial connections etc.
Structure:
stream stream representing the connection to and from the server
connectInfo information required for opening a connection
lastResponse remembers the last response from the server.
progressObservers any object understanding #show: can be registered as a progress observer (login, transfer, etc)
checkForPendingError
If data is waiting, check it to catch any error reports.
In case the response is not an error, push it back.
checkResponse
Get the response from the server and check for errors.
checkResponse:onError:onWarning:
Get the response from the server and check for errors. Invoke one of the blocks if an error or warning is encountered. See class comment for classification of error codes.
checkResponseOnError:onWarning:
Get the response from the server and check for errors. Invoke one of the blocks if an error or warning is encountered. See class comment for classification of error codes.
close
connectionInfo
defaultPortNumber
ensureConnection
fetchNextResponse
fetchPendingResponse
host
host:
isConnected
lastResponse
lastResponse:
logFlag
logProgress:
logProgressToTranscript
messageText
openOnHost:port:
openOnHostNamed:
openOnHostNamed:port:
password
password:
pendingResponses
popResponse
port
port:
progressObservers
pushResponse:
reopen
resetConnectionInfo
response
responseIsError
responseIsWarning
retrieveMIMEDocument:
sendCommand:
sendStreamContents:
stream
stream:
user
user:
ProtocolClientError
Abstract super class for protocol clients
protocolInstance reference to the protocol client throughing the exception. Exception handlers can access the client in order close, respond or whatever may be appropriate
messageText
Return an exception's message text.
protocolInstance
protocolInstance:
response
SMTPClient
This class implements the SMTP (mail sending) protocol specified in RFC 821.
HELO <SP> <domain> <CRLF>
MAIL <SP> FROM:<reverse-path> <CRLF>
RCPT <SP> TO:<forward-path> <CRLF>
DATA <CRLF>
RSET <CRLF>
SEND <SP> FROM:<reverse-path> <CRLF>
SOML <SP> FROM:<reverse-path> <CRLF>
SAML <SP> FROM:<reverse-path> <CRLF>
VRFY <SP> <string> <CRLF>
EXPN <SP> <string> <CRLF>
HELP [<SP> <string>] <CRLF>
NOOP <CRLF>
QUIT <CRLF>
TURN <CRLF>
data:
send the data of a message
defaultPortNumber
deliverMailFrom:to:text:usingServer:
encodeString:
example
example2
initiateSession
EHLO <SP> <domain> <CRLF>
logFlag
login
mailFrom:
MAIL <SP> FROM:<reverse-path> <CRLF>
mailFrom:to:text:
deliver this mail to a list of users. NOTE: the recipient list should be a collection of simple internet style addresses -- no '<>' or '()' stuff
quit
send a QUIT command. This is polite to do, and indeed some servers might drop messages that don't have an associated QUIT
recipient:
specify a recipient for the message. aRecipient should be a bare email address
useHelo
If client use HELO instead of EHLO. HELO is the old protocol and
an old server may require it instead of EHLO.
useHelo:
Tell client to use HELO instead of EHLO. HELO is the old protocol and
an old server may require it instead of EHLO.
TelnetProtocolClient
Abstract super class for protocol clients based on the generic telnet protocol "<response code> <response>"
Structure:
responseCode the numerical (integer) value of the last response code
determineResponseCode
fetchNextResponse
The FTP and similar protocols allow multi-line responses.
If the response is multi-line, the fourth character of the first line is a
$- and the last line repeats the numeric code but the code is followed by
a space.
lastResponse:
lookForCode:
We are expecting a certain code next.
lookForCode:ifDifferent:
We are expecting a certain code next.
rawResponseCodes
responseCode
responseIsContinuation
responseIsContinuation:
responseIsError
responseIsWarning
TelnetProtocolError
Abstract super class for exceptions signalled by clients based on the telnet protocol.
code
isCommandUnrecognized