NSFileHandle (EDExtensions)


Declared In:
NSFileHandle+Extensions.h


Category Description

Various useful extensions to NSFileHandle. Most only work with file handles that represent sockets but this is in a category on NSFileHandle, and not in its subclass EDIPSocket, because this functionality is also useful for plain NSFileHandles that represent sockets. The latter are often created through invocations such as acceptConnectionInBackgroundAndNotify.


Method Types

Endpoints for socket handles
- localPort
- localAddress
- remotePort
- remoteAddress
- remoteHost
Shutdown
- shutdown
- shutdownInput
- shutdownOutput
Non-blocking reads on sockets
- availableDataNonBlocking
- readDataToEndOfFileNonBlocking
- readDataOfLengthNonBlocking:

Instance Methods

availableDataNonBlocking

- (NSData *)availableDataNonBlocking

Calls readDataOfLengthNonBlocking: with a length of UINT_MAX, effectively reading as much data as is available.


localAddress

- (NSString *)localAddress

Returns the address of the local endpoint of the socket in the "typical" dotted numerical notation.


localPort

- (unsigned short)localPort

Returns the port of the local endpoint of the socket.


readDataOfLengthNonBlocking:

- (NSData *)readDataOfLengthNonBlocking:(unsigned int)length

Tries to read length bytes of data. If less data is available it does not block to wait for more but returns whatever is available. If no data is available this method returns nil and not an empty instance of NSData.


readDataToEndOfFileNonBlocking

- (NSData *)readDataToEndOfFileNonBlocking

Calls readDataOfLengthNonBlocking: with a length of UINT_MAX, effectively reading as far towards the end of the file as possible.


remoteAddress

- (NSString *)remoteAddress

Returns the address of the remote endpoint of the socket in the "typical" dotted numerical notation.


remoteHost

- (NSHost *)remoteHost

Returns the host for the remote endpoint of the socket.


remotePort

- (unsigned short)remotePort

Returns the port of the remote endpoint of the socket.


shutdown

- (void)shutdown

Causes the full-duplex connection on the socket to be shut down.


shutdownInput

- (void)shutdownInput

Causes part of the full-duplex connection on the socket to be shut down; further receives will be disallowed.


shutdownOutput

- (void)shutdownOutput

Causes part of the full-duplex connection on the socket to be shut down; further sends will be disallowed.


Version 2.0 Copyright ©2002. All Rights Reserved.