haiku/headers/os/net/NetEndpoint.h
Axel Dörfler 241b048033 * Fixed build of libnetapi.so - it probably won't work for now, though, have a look
at the comment in r5_compatibility.h.
* Intentionally broke source compatibility and removed all that outdated Nettle stuff.
* Also, I took the liberty of making m_init private and rename it to fInit - again, this
  will only affect source compatibility.
* Rewrote NetEndpoint.h
* Fixed quite a few small bugs around the code that I touched, for example in NetAddress,
  SetTo() never set fInit, and therefore could be wrong.
* Some cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18680 a95241bf-73f2-0310-859d-f6bbb57e9c96
2006-08-29 00:19:23 +00:00

93 lines
2.6 KiB
C++

/*
* Copyright 2006, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef H_NETENDPOINT
#define H_NETENDPOINT
#include <BeBuild.h>
#include <Archivable.h>
#include <NetAddress.h>
#include <NetBuffer.h>
#include <SupportDefs.h>
#include <sys/socket.h>
class BNetEndpoint : public BArchivable {
public:
BNetEndpoint(int type = SOCK_STREAM);
BNetEndpoint(int family, int type, int protocol);
BNetEndpoint(const BNetEndpoint& other);
BNetEndpoint(BMessage* archive);
virtual ~BNetEndpoint();
BNetEndpoint& operator=(const BNetEndpoint& other);
status_t InitCheck();
virtual status_t Archive(BMessage* into, bool deep = true) const;
static BArchivable* Instantiate(BMessage* archive);
status_t SetProtocol(int protocol);
int SetOption(int32 option, int32 level, const void* data, unsigned int dataSize);
int SetNonBlocking(bool on = true);
int SetReuseAddr(bool on = true);
const BNetAddress& LocalAddr();
const BNetAddress& RemoteAddr();
int Socket() const;
virtual void Close();
virtual status_t Bind(const BNetAddress& addr);
virtual status_t Bind(int port = 0);
virtual status_t Connect(const BNetAddress& addr);
virtual status_t Connect(const char* addr, int port);
virtual status_t Listen(int backlog = 5);
virtual BNetEndpoint* Accept(int32 timeout = -1);
int Error() const;
char* ErrorStr() const;
virtual int32 Send(const void* buffer, size_t size, int flags = 0);
virtual int32 Send(BNetBuffer& buffer, int flags = 0);
virtual int32 SendTo(const void* buffer, size_t size,
const BNetAddress& to, int flags = 0);
virtual int32 SendTo(BNetBuffer& buffer, const BNetAddress& to,
int flags = 0);
void SetTimeout(bigtime_t usec);
virtual int32 Receive(void* buffer, size_t size, int flags = 0);
virtual int32 Receive(BNetBuffer& buffer, size_t size, int flags = 0);
virtual int32 ReceiveFrom(void* buffer, size_t size, BNetAddress& from,
int flags = 0);
virtual int32 ReceiveFrom(BNetBuffer& buffer, size_t size,
BNetAddress& from, int flags = 0);
virtual bool IsDataPending(bigtime_t timeout = 0);
private:
virtual void _ReservedBNetEndpointFBCCruft1();
virtual void _ReservedBNetEndpointFBCCruft2();
virtual void _ReservedBNetEndpointFBCCruft3();
virtual void _ReservedBNetEndpointFBCCruft4();
virtual void _ReservedBNetEndpointFBCCruft5();
virtual void _ReservedBNetEndpointFBCCruft6();
status_t fInit;
int fSocket;
bigtime_t fTimeout;
int fLastError;
BNetAddress fAddr;
BNetAddress fPeer;
int32 _reserved[18];
};
#endif // H_NETENDPOINT