SocketAddress.h

00001 //
00002 // $Id: SocketAddress.h,v 1.21 2007/03/08 19:59:21 will_mason Exp $
00003 //
00004 // vi: set ft=objc:
00005 
00006 /*
00007  * ObjectiveLib - a library of containers and algorithms for Objective-C
00008  *
00009  * Copyright (c) 2004-2007
00010  * Will Mason
00011  *
00012  * Portions:
00013  *
00014  * Copyright (c) 1994
00015  * Hewlett-Packard Company
00016  *
00017  * Copyright (c) 1996,1997
00018  * Silicon Graphics Computer Systems, Inc.
00019  *
00020  * Copyright (c) 1997
00021  * Moscow Center for SPARC Technology
00022  *
00023  * Copyright (c) 1999 
00024  * Boris Fomitchev
00025  *
00026  * This library is free software; you can redistribute it and/or
00027  * modify it under the terms of the GNU Lesser General Public
00028  * License as published by the Free Software Foundation; either
00029  * version 2.1 of the License, or (at your option) any later version.
00030  *
00031  * This library is distributed in the hope that it will be useful,
00032  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00033  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00034  * Lesser General Public License for more details.
00035  *
00036  * You should have received a copy of the GNU Lesser General Public
00037  * License along with this library; if not, write to the Free Software
00038  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00039  *
00040  * You may contact the author at will_mason@users.sourceforge.net.
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

ObjectiveLibGenerated Sun Apr 22 15:17:59 2007, © 2004-2007 Will Mason
SourceForge.net Logo