00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037 
00038 
00039 
00040 
00041 
00042 
00043 #if !defined(SOCKETADDRESS_OL_GUARD)
00044 #define SOCKETADDRESS_OL_GUARD
00045 
00046 #include <ObjectiveLib/ObjectBase.h>
00047 #if defined(OL_HAVE_INTTYPES_H)
00048 #include <inttypes.h>
00049 #else
00050 #include <stdint.h>
00051 #endif
00052 
00053 @class OLText;
00054 @class OLVector;
00055 struct sockaddr;
00056 struct sockaddr_in;
00057 struct sockaddr_in6;
00058 struct sockaddr_un;
00059 
00068 @interface OLSocketAddress :
00069 #if defined(OL_NO_OPENSTEP)
00070     Object
00071 #else
00072     NSObject <NSCopying>
00073 #endif
00074 {
00075 }
00076 
00077 #if defined(OL_NO_OPENSTEP)
00078 
00083 - (id) copy;
00084 #else
00085 
00091 - (id) copyWithZone: (NSZone*)zone;
00092 #endif
00093 
00103 - (OLText*) description;
00104 
00111 - (unsigned) hash;
00112 
00120 - (const struct sockaddr*) hostRepresentation;
00121 
00128 - (unsigned) hostRepresentationLength;
00129 
00130 @end
00131 
00140 @interface OLInternetAddress : OLSocketAddress
00141 {
00142 @protected
00146     char*           canonicalName;
00147 
00151     int             socketType;
00152 }
00153 
00162 + (OLInternetAddress*) addressWithCurrentHostAndPort: (uint16_t)port;
00163 
00176 + (OLInternetAddress*) addressWithCurrentHostAndService: (const char*)service;
00177 
00187 + (OLInternetAddress*) addressWithHost: (const char*)name port: (uint16_t)port;
00188 
00202 + (OLInternetAddress*) addressWithHost: (const char*)name service: (const char*)service;
00203 
00211 + (OLVector*) allAddressesWithHost: (const char*)name port: (uint16_t)port;
00219 + (OLVector*) allAddressesWithHost: (const char*)name service: (const char*)service;
00220 
00225 #if defined(OL_NO_OPENSTEP)
00226 + (id) initialize;
00227 #else
00228 + (void) initialize;
00229 #endif
00230 
00237 + (OLInternetAddress*) loopbackWithPort: (uint16_t)port;
00238 
00245 + (OLInternetAddress*) loopbackWithService: (const char*)service;
00246 
00252 + (BOOL) preferIPv6Addresses;
00253 
00259 + (void) setPreferIPv6Addresses: (BOOL)state;
00260 
00264 
00268 #if defined(OL_NO_OPENSTEP)
00269 - (id) free;
00270 #else
00271 - (void) dealloc;
00272 #endif
00273 
00274 
00282 - (const char*) canonicalName;
00283 
00291 - (BOOL) isLocalWildcard;
00292 
00298 - (uint16_t) port;
00299 
00309 - (int) socketType;
00310 
00311 @end
00312 
00325 @interface OLInternet4Address : OLInternetAddress
00326 {
00327 @protected
00331     struct sockaddr_in* hostRep;
00332 }
00333 
00337 
00344 - (id) init;
00345 
00352 - (id) initWithPort: (uint16_t)port;
00353 #if defined(OL_NO_OPENSTEP)
00354 - (id) free;
00355 #else
00356 - (void) dealloc;
00357 #endif
00358 
00359 
00360 #if defined(OL_NO_OPENSTEP)
00361 - (id) copy;
00362 #else
00363 - (id) copyWithZone: (NSZone*)zone;
00364 #endif
00365 
00376 - (OLText*) description;
00377 - (const struct sockaddr*) hostRepresentation;
00378 - (unsigned) hostRepresentationLength;
00379 
00386 - (BOOL) isEqual: (id)object;
00387 - (BOOL) isLocalWildcard;
00388 - (uint16_t) port;
00389 
00390 @end
00391 
00392 #if defined(OL_HAVE_INET6_SOCKETS)
00393 
00406 @interface OLInternet6Address : OLInternetAddress
00407 {
00408 @protected
00412     struct sockaddr_in6* hostRep;
00413 }
00414 
00418 
00423 - (id) init;
00424 
00429 - (id) initWithPort: (uint16_t)port;
00430 #if defined(OL_NO_OPENSTEP)
00431 - (id) free;
00432 #else
00433 - (void) dealloc;
00434 #endif
00435 
00436 #if defined(OL_NO_OPENSTEP)
00437 - (id) copy;
00438 #else
00439 - (id) copyWithZone: (NSZone*)zone;
00440 #endif
00441 
00446 - (OLText*) description;
00447 - (const struct sockaddr*) hostRepresentation;
00448 - (unsigned) hostRepresentationLength;
00449 
00456 - (BOOL) isEqual: (id)object;
00457 - (BOOL) isLocalWildcard;
00458 - (uint16_t) port;
00459 
00460 @end
00461 
00462 #endif
00463 
00464 #if defined(OL_HAVE_UNIX_SOCKETS)
00465 
00477 @interface OLUnixAddress : OLSocketAddress
00478 {
00479 @protected
00483     struct sockaddr_un* hostRep;
00484 }
00485 
00495 + (id) addressWithPath: (const char*)pth;
00496 
00500 
00510 - (id) initWithPath: (const char*)pth;
00511 
00515 #if defined(OL_NO_OPENSTEP)
00516 - (id) free;
00517 #else
00518 - (void) dealloc;
00519 #endif
00520 
00521 
00522 #if defined(OL_NO_OPENSTEP)
00523 - (id) copy;
00524 #else
00525 - (id) copyWithZone: (NSZone*)zone;
00526 #endif
00527 
00539 - (OLText*) description;
00540 - (const struct sockaddr*) hostRepresentation;
00541 - (unsigned) hostRepresentationLength;
00542 
00549 - (BOOL) isEqual: (id)object;
00550 
00556 - (const char*) path;
00557 
00558 @end
00559 
00560 #endif
00561 
00562 #endif