/usr/include/GNUstep/Foundation/NSPort.h is in libgnustep-base-dev 1.24.7-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | /** Interface for abstract superclass NSPort for use with NSConnection
Copyright (C) 1997,2002 Free Software Foundation, Inc.
Written by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
Created: August 1997
This file is part of the GNUstep Base Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02111 USA.
AutogsdocSource: NSPort.m
AutogsdocSource: NSSocketPort.m
AutogsdocSource: NSMessagePort.m
*/
#ifndef __NSPort_h_GNUSTEP_BASE_INCLUDE
#define __NSPort_h_GNUSTEP_BASE_INCLUDE
#import <GNUstepBase/GSVersionMacros.h>
#import <Foundation/NSObject.h>
#import <Foundation/NSMapTable.h>
#if defined(__MINGW__)
#include <winsock2.h>
#include <wininet.h>
#else
#include <sys/socket.h>
#define SOCKET int
#endif
#if defined(__cplusplus)
extern "C" {
#endif
@class NSMutableArray;
@class NSConnection;
@class NSDate;
@class NSRunLoop;
@class NSString;
@class NSPortMessage;
@class NSHost;
@interface NSObject(NSPortDelegateMethods)
/** <override-dummy />
* Subclasses of NSPort send this message to their delegate on receipt
* of a port message.
*/
- (void) handlePortMessage: (NSPortMessage*)aMessage;
@end
/**
* <p><code>NSPort</code> is an abstract class defining interfaces underlying
* communications in the distributed objects framework. Each side of a
* connection will have an <code>NSPort</code> object, responsible for sending
* and receiving [NSPortMessage]s, which are then passed to delegates when
* received. The <code>NSPort</code> must be added to the [NSRunLoop] as an
* input source.</p>
*
* <p>This class also implements the functionality of the
* <code><em>NSMachPort</em></code> class on OS X.</p>
*/
@interface NSPort : NSObject <NSCoding, NSCopying>
{
#if GS_EXPOSE(NSPort)
BOOL _is_valid;
id _delegate;
#endif
}
/**
* Basic constructor returns object capable of send and receive.<br />
* By default, the port returned is an instance of [NSMessagePort]
* capable only of host-local communication. However, the
* <code>NSPortIsMessagePort</code> user default may be set to NO to
* change the behavior so that the returned value is an instance of
* the [NSSocketPort] class.
*/
+ (NSPort*) port;
/**
* NSMachPort compatibility method.
*/
+ (NSPort*) portWithMachPort: (NSInteger)machPort;
/**
* Returns the object that received messages will be passed off to.
*/
- (id) delegate;
/**
* Sets the object that received messages will be passed off to.
*/
- (void) setDelegate: (id)anObject;
/**
* Basic initializer sets up object capable of send and receive.
* See +port for more details.
*/
- (id) init;
/**
* NSMachPort compatibility method.
*/
- (id) initWithMachPort: (NSInteger)machPort;
/**
* NSMachPort compatibility.
*/
- (NSInteger) machPort;
/**
* Mark port as invalid, deregister with listeners and cease further network
* operations. Subclasses should override and call super.
*/
- (void) invalidate;
/**
* Returns whether port has been marked invalid.
*/
- (BOOL) isValid;
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
/**
* Adds to run loop as input source to be notified for input in given mode.
* This method is for use by subclasses.
*/
- (void) addConnection: (NSConnection*)aConnection
toRunLoop: (NSRunLoop*)aLoop
forMode: (NSString*)aMode;
/**
* Removes from run loop as input source to be notified for input in given mode.
* This method is for use by subclasses.
*/
- (void) removeConnection: (NSConnection*)aConnection
fromRunLoop: (NSRunLoop*)aLoop
forMode: (NSString*)aMode;
/**
* Returns amount of space used for header info at beginning of messages.
* Subclasses should override (this implementation returns 0).
*/
- (NSUInteger) reservedSpaceLength;
/**
* Internal method for sending message, for use by subclasses.
*/
- (BOOL) sendBeforeDate: (NSDate*)when
msgid: (NSInteger)msgid
components: (NSMutableArray*)components
from: (NSPort*)receivingPort
reserved: (NSUInteger)length;
/**
* Internal method for sending message, for use by subclasses.
*/
- (BOOL) sendBeforeDate: (NSDate*)when
components: (NSMutableArray*)components
from: (NSPort*)receivingPort
reserved: (NSUInteger)length;
#endif
@end
/**
* Notification posted when an instance of [NSPort] or a subclass becomes
* invalid.
*/
GS_EXPORT NSString* const NSPortDidBecomeInvalidNotification;
#define PortBecameInvalidNotification NSPortDidBecomeInvalidNotification
#if OS_API_VERSION(GS_API_MACOSX, GS_API_LATEST)
/**
* Native socket type.
*/
typedef SOCKET NSSocketNativeHandle;
/**
* <p>An [NSPort] implementation for network object communications based on
* BSD sockets. Can be used for interthread/interprocess
* communications between same or different hosts (though on same host
* [NSMessagePort] will be more efficient).</p>
*
* <p>Note that this class is incompatible with the latest OS X version.</p>
*/
@interface NSSocketPort : NSPort
{
#if GS_EXPOSE(NSSocketPort)
NSRecursiveLock *myLock;
NSHost *host; /* OpenStep host for this port. */
NSString *address; /* Forced internet address. */
uint16_t portNum; /* TCP port in host byte order. */
SOCKET listener;
NSMapTable *handles; /* Handles indexed by socket. */
#if defined(__MINGW__)
WSAEVENT eventListener;
NSMapTable *events;
#endif
#endif
#if GS_NONFRAGILE
#else
/* Pointer to private additional data used to avoid breaking ABI
* when we don't have the non-fragile ABI available.
* Use this mechanism rather than changing the instance variable
* layout (see Source/GSInternal.h for details).
*/
@private id _internal GS_UNUSED_IVAR;
#endif
}
/**
* Look up and return an existing <code>NSSocketPort</code> given a host and
* number, or return nil if one has not been created.
*/
+ (NSSocketPort*) existingPortWithNumber: (uint16_t)number
onHost: (NSHost*)aHost;
/**
* This is the preferred initialisation method for <code>NSSocketPort</code>.
* <br/>
* number should be a TCP/IP port number or may be zero for a port on
* the local host.<br/>
* aHost should be the host for the port or may be nil for the local
* host.<br/>
* addr is the IP address that MUST be used for this port - if it is nil
* then, for the local host, the port uses ALL IP addresses, and for a
* remote host, the port will use the first address that works.<br/>
* shouldListen specifies whether to listen on the port initially.
*/
+ (NSSocketPort*) portWithNumber: (uint16_t)number
onHost: (NSHost*)aHost
forceAddress: (NSString*)addr
listener: (BOOL)shouldListen;
/**
* Returns IP address of underlying socket.
*/
- (NSString*) address;
/**
* This is a callback method used by the NSRunLoop class to determine which
* descriptors to watch for the port.
*/
- (void) getFds: (NSInteger*)fds count: (NSInteger*)count;
/**
* Delegates processing of a message.
*/
- (void) handlePortMessage: (NSPortMessage*)m;
/**
* Returns host that the underlying socket is connected to.
*/
- (NSHost*) host;
/**
* Returns port number of underlying socket.
*/
- (uint16_t) portNumber;
@end
/**
* An [NSPort] implementation for network object communications
* which can be used for interthread/interprocess communications
* on the same host, but not between different hosts.
*/
@interface NSMessagePort : NSPort
{
#if GS_EXPOSE(NSMessagePort)
void *_internal;
#endif
}
@end
#endif
#if defined(__cplusplus)
}
#endif
#endif /* __NSPort_h_GNUSTEP_BASE_INCLUDE */
|