2 * Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
10 #include <SupportDefs.h>
11 #include <Archivable.h>
13 #include <netinet/in.h>
14 #include <sys/socket.h>
17 class BNetAddress
: public BArchivable
{
19 BNetAddress(BMessage
* archive
);
20 virtual ~BNetAddress();
22 virtual status_t
Archive(BMessage
* into
, bool deep
= true) const;
23 static BArchivable
* Instantiate(BMessage
* archive
);
25 BNetAddress(const char* hostname
= 0, unsigned short port
= 0);
26 BNetAddress(const struct sockaddr_in
& addr
);
27 BNetAddress(in_addr addr
, int port
= 0);
28 BNetAddress(uint32 addr
, int port
= 0);
29 BNetAddress(const BNetAddress
& other
);
30 BNetAddress(const char* hostname
, const char* protocol
,
33 BNetAddress
& operator=(const BNetAddress
&);
35 status_t
InitCheck() const;
37 status_t
SetTo(const char* hostname
, const char* protocol
,
39 status_t
SetTo(const char* hostname
= NULL
, unsigned short port
= 0);
40 status_t
SetTo(const struct sockaddr_in
& addr
);
41 status_t
SetTo(in_addr addr
, int port
= 0);
42 status_t
SetTo(uint32 addr
= INADDR_ANY
, int port
= 0);
44 status_t
GetAddr(char* hostname
= NULL
,
45 unsigned short* port
= NULL
) const;
46 status_t
GetAddr(struct sockaddr_in
& addr
) const;
47 status_t
GetAddr(in_addr
& addr
, unsigned short* port
= NULL
) const;
49 // TODO: drop this compatibility cruft method after R1
53 virtual void _ReservedBNetAddressFBCCruft1();
54 virtual void _ReservedBNetAddressFBCCruft2();
55 virtual void _ReservedBNetAddressFBCCruft3();
56 virtual void _ReservedBNetAddressFBCCruft4();
57 virtual void _ReservedBNetAddressFBCCruft5();
58 virtual void _ReservedBNetAddressFBCCruft6();
64 int32 fPrivateData
[7];
67 #endif // H_NETADDRESS