Up
Authors
- Andrew Ruder (
aeruder@ksu.edu
)
-
Version: Revision 1
Date: November 8, 2003
Copyright: (C) Andrew Ruder
- Declared in:
- NetTCP.h
- Conforms to:
- NetObject
Instance Variables
Method summary
- (void)
abortConnection;
- (void)
connectionLost;
Cleans up the connection placeholder.
- (id)
dataReceived: (NSData*)data;
This shouldn't happen while a class is connecting, but included to conform to the
<NetObject>
protocol.
- (id<
NetObject>)
netObject;
Returns the object that will be connected by this placeholder object.
- (id<
NetTransport>)
transport;
Returns the transport used by this object. Will not be the same transport given to the net object when the connection is made.
Instance Variables for TCPConnecting Class
@protected id netObject;
Description forthcoming.
@protected NSTimer* timeout;
Description forthcoming.
@protected id transport;
Description forthcoming.
- Declared in:
- NetTCP.h
- Conforms to:
- NetPort
TCPPort is a class that is used to bind a descriptor to a certain TCP/IP port and listen for connections. When a connection is received, it will create a class set with
-setNetObject:
and set it up with the new connection.
Instance Variables
Method summary
- (void)
close;
Closes the descriptor.
- (void)
connectionLost;
Called when the connection is closed. This will call
-close
- (int)
desc;
Returns the low-level file descriptor for the port.
- (id)
initOnHost: (NSHost*)aHost
onPort: (uint16_t)aPort;
Initializes a port on
aHost and binds it to port
aPort. If
aHost is
nil
, it will set it up on all addresses on the local machine. Using zero for
aPort will use a random currently available port number. Use
-port
to find out where it is actually bound to.
- (id)
initOnPort: (uint16_t)aPort;
- (id)
newConnection;
Called when a new connection occurs. Will initialize a new object of the class set with
-setNetObject:
with the new connection.
- (uint16_t)
port;
Returns the port that this TCPPort is currently bound to.
- (id)
setNetObject: (Class)aClass;
Sets the class that will be initialized if a connection occurs on this port. If
aClass does not implement the
<NetObject>
protocol, will throw a FatalNetException.
Instance Variables for TCPPort Class
@protected int desc;
Description forthcoming.
@protected Class netObjectClass;
Description forthcoming.
@protected uint16_t port;
Description forthcoming.
- Declared in:
- NetTCP.h
Used for certain operations in the TCP/IP system. There is only one instance of this class at a time, used
+sharedInstance
to get this instance.
Instance Variables
Method summary
+ (id)
sharedInstance;
Returns the one instance of TCPSystem currently in existence.
- (id<
NetObject>)
connectNetObject: (id<
NetObject>)netObject
toHost: (NSHost*)aHost
onPort: (uint16_t)aPort
withTimeout: (int)aTimeout;
Will connect the object netObject to host aHost on port aPort. If this connection doesn't happen in aTimeout seconds or some other error occurs, it will return nil
and the error string and error number shall be set accordingly. Otherwise this will return netObject
- (
TCPConnecting*)
connectNetObjectInBackground: (id<
NetObject>)netObject
toHost: (NSHost*)aHost
onPort: (uint16_t)aPort
withTimeout: (int)aTimeout;
Connects netObject to host aHost on the port aPort. Returns a place holder object that finishes the connection in the background. The placeholder will fail if the connection does not occur in aTimeout seconds. Returns nil
if an error occurs and sets the error string and error number accordingly.
- (int)
errorNumber;
Returns the errno of the last error that occurred. If it is some other non-system error, this will be zero, but the error string shall be set accordingly.
- (NSString*)
errorString;
Returns the error string of the last error that occurred.
- (NSHost*)
hostFromHostOrderInteger: (uint32_t)ip;
Returns a host from a host order 32-bit integer ip address.
- (NSHost*)
hostFromNetworkOrderInteger: (uint32_t)ip;
Returns a host from a network order 32-bit integer ip address.
Instance Variables for TCPSystem Class
@protected int errorNumber;
Description forthcoming.
@protected NSString* errorString;
Description forthcoming.
- Declared in:
- NetTCP.h
- Conforms to:
- NetTransport
Handles the actual TCP/IP transfer of data.
Instance Variables
Method summary
- (void)
close;
Closes the transport nd makes sure there is no more incoming or outgoing data on the connection.
- (int)
desc;
Returns the low level file descriptor that is used internally.
- (id)
initWithDesc: (int)aDesc
withRemoteHost: (NSHost*)theAddress;
Initializes the transport with the file descriptor aDesc. theAddress is the host that the flie descriptor is connected to.
- (BOOL)
isDoneWriting;
Returns YES
if there is no more data to write in the buffer and NO
if there is.
- (NSHost*)
localHost;
Returns a NSHost of the local side of a connection.
- (NSData*)
readData: (int)maxDataSize;
Handles the actual reading of data from the connection. Throws an exception if an error occurs while reading data.
- (NSHost*)
remoteHost;
Returns a NSHost of the remote side of a connection.
- (id)
writeData: (NSData*)aData;
If aData is nil
, this will physically transport the data to the connected end. Otherwise this will put the data in the buffer of data that needs to be written to the connection when next possible.
Instance Variables for TCPTransport Class
@protected BOOL connected;
Description forthcoming.
@protected int desc;
Description forthcoming.
@protected NSHost* localHost;
Description forthcoming.
@protected NSHost* remoteHost;
Description forthcoming.
@protected NSMutableData* writeBuffer;
Description forthcoming.
- Declared in:
- NetTCP.h
Method summary
- (id)
connectingFailed: (NSString*)aError;
Tells the class implementing this protocol that the error in aError has occurred and the connection will not be established
- (id)
connectingStarted: (
TCPConnecting*)aConnection;
Tells the class implementing this protocol that the connection has begun and will be using the connection place holder aConnection
NSString* NetclassesErrorAborted;
The error message used when a connection is aborted.
NSString* NetclassesErrorBadAddress;
Could be the current error string if the error number is zero and some error has occurred. Indicates that a NSHost returned an address that was invalid.
NSString* NetclassesErrorTimeout;
If an error occurs and error number is zero, this could be the error string. This error occurs when some operation times out.
Up