* 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
This commit is contained in:
Axel Dörfler
2006-08-29 00:19:23 +00:00
parent 036caeb9cf
commit 241b048033
8 changed files with 706 additions and 1073 deletions
+42 -86
View File
@@ -1,105 +1,61 @@
/*=--------------------------------------------------------------------------=*
* NetAddress.h -- Interface definition for the BNetAddress class.
*
* Written by S.T. Mansfield ([email protected])
*=--------------------------------------------------------------------------=*
* Copyright (c) 2002, The OpenBeOS project.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*=--------------------------------------------------------------------------=*
/*
* Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef H_NETADDRESS
#define H_NETADDRESS
#ifndef _NETADDRESS_H
#define _NETADDRESS_H
#include <BeBuild.h>
#include <SupportDefs.h>
#include <Archivable.h>
#include <socket.h>
/*
* Empty forward declaration to satisfy the GetImpl method.
*/
class NLAddress;
#include <netinet/in.h>
#include <sys/socket.h>
class BNetAddress : public BArchivable
{
public:
BNetAddress( BMessage* archive );
virtual ~BNetAddress();
virtual status_t Archive( BMessage* into, bool deep = true ) const;
static BArchivable* Instantiate( BMessage* archive );
class BNetAddress : public BArchivable {
public:
BNetAddress(BMessage* archive);
virtual ~BNetAddress();
BNetAddress( const char* hostname = 0, unsigned short port = 0 );
BNetAddress( const struct sockaddr_in& sa );
BNetAddress( in_addr addr, int port = 0 );
BNetAddress( uint32 addr, int port = 0 );
BNetAddress( const BNetAddress& refparam );
BNetAddress( const char* hostname, const char* protocol, const char* service );
virtual status_t Archive(BMessage* into, bool deep = true) const;
static BArchivable* Instantiate(BMessage* archive);
BNetAddress& operator=( const BNetAddress& );
BNetAddress(const char* hostname = 0, unsigned short port = 0);
BNetAddress(const struct sockaddr_in& addr);
BNetAddress(in_addr addr, int port = 0);
BNetAddress(uint32 addr, int port = 0);
BNetAddress(const BNetAddress& other);
BNetAddress(const char* hostname, const char* protocol, const char* service);
status_t InitCheck();
BNetAddress& operator=(const BNetAddress&);
status_t SetTo( const char* hostname, const char* protocol, const char* service );
status_t SetTo( const char* hostname = NULL, unsigned short port = 0 );
status_t SetTo( const struct sockaddr_in& sa );
status_t SetTo( in_addr addr, int port = 0 );
status_t SetTo( uint32 addr = INADDR_ANY, int port = 0 );
status_t InitCheck();
status_t GetAddr( char* hostname = NULL, unsigned short* port = NULL ) const;
status_t GetAddr( struct sockaddr_in& sa ) const;
status_t GetAddr( in_addr& addr, unsigned short* port = NULL ) const;
status_t SetTo(const char* hostname, const char* protocol, const char* service);
status_t SetTo(const char* hostname = NULL, unsigned short port = 0);
status_t SetTo(const struct sockaddr_in& addr);
status_t SetTo(in_addr addr, int port = 0);
status_t SetTo(uint32 addr = INADDR_ANY, int port = 0);
inline NLAddress *GetImpl() const;
status_t GetAddr(char* hostname = NULL, unsigned short* port = NULL) const;
status_t GetAddr(struct sockaddr_in& addr) const;
status_t GetAddr(in_addr& addr, unsigned short* port = NULL) const;
protected:
status_t m_init;
private:
virtual void _ReservedBNetAddressFBCCruft1();
virtual void _ReservedBNetAddressFBCCruft2();
virtual void _ReservedBNetAddressFBCCruft3();
virtual void _ReservedBNetAddressFBCCruft4();
virtual void _ReservedBNetAddressFBCCruft5();
virtual void _ReservedBNetAddressFBCCruft6();
private:
virtual void _ReservedBNetAddressFBCCruft1();
virtual void _ReservedBNetAddressFBCCruft2();
virtual void _ReservedBNetAddressFBCCruft3();
virtual void _ReservedBNetAddressFBCCruft4();
virtual void _ReservedBNetAddressFBCCruft5();
virtual void _ReservedBNetAddressFBCCruft6();
// Private copy helper.
status_t clone( const BNetAddress& RefParam );
int32 fFamily; // Encapsulation of sockaddr::sin_family
int32 fPort; // Encapsulation of sockaddr::sin_port
int32 fAddress; // Encapsulation of sockaddr::sin_addr.s_addr
// Not used, here to maintain R5 binary compatiblilty.
int32 fPrivateData[6];
status_t fInit;
int32 fFamily;
int32 fPort;
int32 fAddress;
int32 fPrivateData[6];
};
inline NLAddress* BNetAddress::GetImpl( void ) const
{
return NULL; // No Nettle backward compatibility
}
#endif // <-- #ifndef _NETADDRESS_H
/*=------------------------------------------------------------------- End -=*/
#endif // H_NETADDRESS
+66 -108
View File
@@ -1,128 +1,86 @@
/*=--------------------------------------------------------------------------=*
* NetBuffer.h -- Interface definition for the BNetBuffer class.
*
* Written by S.T. Mansfield ([email protected])
*=--------------------------------------------------------------------------=*
* Copyright (c) 2002, The OpenBeOS project.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*=--------------------------------------------------------------------------=*
/*
* Copyright 2002-2006, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _NETBUFFER_H
#define _NETBUFFER_H
#include <BeBuild.h>
#include <SupportDefs.h>
#include <Archivable.h>
#include <socket.h>
/*
* Empty forward declaration to satisfy the GetImpl method.
*/
class NLPacket;
#include <sys/socket.h>
class BNetBuffer : public BArchivable
{
public:
BNetBuffer(size_t size = 0);
virtual ~BNetBuffer();
status_t InitCheck();
class BNetBuffer : public BArchivable {
public:
BNetBuffer(size_t size = 0);
virtual ~BNetBuffer();
BNetBuffer(BMessage *archive);
virtual status_t Archive(BMessage *into, bool deep = true) const;
static BArchivable *Instantiate(BMessage *archive);
status_t InitCheck();
BNetBuffer(const BNetBuffer &);
BNetBuffer& operator=(const BNetBuffer &);
BNetBuffer(BMessage* archive);
virtual status_t Archive(BMessage* into, bool deep = true) const;
static BArchivable* Instantiate(BMessage* archive);
// Mutators.
status_t AppendInt8(int8);
status_t AppendUint8(uint8);
status_t AppendInt16(int16);
status_t AppendUint16(uint16);
status_t AppendInt32(int32);
status_t AppendUint32(uint32);
status_t AppendFloat(float);
status_t AppendDouble(double);
status_t AppendString(const char *);
status_t AppendData(const void *, size_t);
status_t AppendMessage(const BMessage &);
status_t AppendInt64(int64);
status_t AppendUint64(uint64);
BNetBuffer(const BNetBuffer &);
BNetBuffer& operator=(const BNetBuffer &);
status_t RemoveInt8(int8 &);
status_t RemoveUint8(uint8 &);
status_t RemoveInt16(int16 &);
status_t RemoveUint16(uint16 &);
status_t RemoveInt32(int32 &);
status_t RemoveUint32(uint32 &);
status_t RemoveFloat(float &);
status_t RemoveDouble(double &);
status_t RemoveString(char *, size_t);
status_t RemoveData(void *, size_t);
status_t RemoveMessage(BMessage &);
status_t RemoveInt64(int64 &);
status_t RemoveUint64(uint64 &);
// Mutators.
status_t AppendInt8(int8);
status_t AppendUint8(uint8);
status_t AppendInt16(int16);
status_t AppendUint16(uint16);
status_t AppendInt32(int32);
status_t AppendUint32(uint32);
status_t AppendFloat(float);
status_t AppendDouble(double);
status_t AppendString(const char *);
status_t AppendData(const void *, size_t);
status_t AppendMessage(const BMessage &);
status_t AppendInt64(int64);
status_t AppendUint64(uint64);
// Accessors.
unsigned char *Data() const;
size_t Size() const;
size_t BytesRemaining() const;
status_t RemoveInt8(int8 &);
status_t RemoveUint8(uint8 &);
status_t RemoveInt16(int16 &);
status_t RemoveUint16(uint16 &);
status_t RemoveInt32(int32 &);
status_t RemoveUint32(uint32 &);
status_t RemoveFloat(float &);
status_t RemoveDouble(double &);
status_t RemoveString(char *, size_t);
status_t RemoveData(void *, size_t);
status_t RemoveMessage(BMessage &);
status_t RemoveInt64(int64 &);
status_t RemoveUint64(uint64 &);
inline NLPacket *GetImpl() const;
// Accessors.
unsigned char* Data() const;
size_t Size() const;
size_t BytesRemaining() const;
protected:
// Attributes.
status_t m_init;
private:
virtual void _ReservedBNetBufferFBCCruft1();
virtual void _ReservedBNetBufferFBCCruft2();
virtual void _ReservedBNetBufferFBCCruft3();
virtual void _ReservedBNetBufferFBCCruft4();
virtual void _ReservedBNetBufferFBCCruft5();
virtual void _ReservedBNetBufferFBCCruft6();
private:
virtual void _ReservedBNetBufferFBCCruft1();
virtual void _ReservedBNetBufferFBCCruft2();
virtual void _ReservedBNetBufferFBCCruft3();
virtual void _ReservedBNetBufferFBCCruft4();
virtual void _ReservedBNetBufferFBCCruft5();
virtual void _ReservedBNetBufferFBCCruft6();
unsigned char* fData;
int32 fDataSize;
int32 fStackSize;
int32 fCapacity;
// Not used, here to maintain R5 binary compatiblilty.
int32 fPrivateData[5];
// Private class helpers.
status_t clone( const BNetBuffer& );
status_t dpop( int32, int32, void* );
status_t dpush( int32, int32, const void* );
status_t resize( int32 NewSize, bool RegenStack = false );
// Private class helpers.
status_t clone(const BNetBuffer&);
status_t dpop(int32, int32, void*);
status_t dpush(int32, int32, const void*);
status_t resize(int32 newSize, bool regenStack = false);
status_t fInit;
uint8* fData;
int32 fDataSize;
int32 fStackSize;
int32 fCapacity;
int32 _reserved[5];
};
inline NLPacket* BNetBuffer::GetImpl( void ) const
{
return NULL; // No Nettle backward compatibility
}
#endif // <-- #ifndef _NETBUFFER_H
/*=------------------------------------------------------------------- End -=*/
#endif // _NETBUFFER_H
+65 -256
View File
@@ -1,283 +1,92 @@
//------------------------------------------------------------------------------
// Copyright (c) 2001-2004, Haiku
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//------------------------------------------------------------------------------
/*
* Copyright 2006, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef H_NETENDPOINT
#define H_NETENDPOINT
#ifndef _NETENDPOINT_H
#define _NETENDPOINT_H
#include <BeBuild.h>
#include <SupportDefs.h>
#include <Archivable.h>
#include <NetAddress.h>
#include <NetBuffer.h>
#include <SupportDefs.h>
#include <sys/socket.h>
#include <NetAddress.h>
#include <NetBuffer.h>
/*
* BNetEndpoint
*
* BNetEndpoint is an object that implements a networking endpoint abstraction.
* Think of it as an object-oriented socket. BNetEndpoint provides
* various ways to send and receive data, establish network connections, bind
* to local addresses, and listen for and accept new connections.
*
*/
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();
// Nettle forward declarations
class NLEndpoint;
BNetEndpoint& operator=(const BNetEndpoint& other);
status_t InitCheck();
class BNetEndpoint : public BArchivable
{
public:
virtual status_t Archive(BMessage* into, bool deep = true) const;
static BArchivable* Instantiate(BMessage* archive);
BNetEndpoint(int type = SOCK_STREAM);
BNetEndpoint(int family, int type, int protocol);
BNetEndpoint(const BNetEndpoint &);
BNetEndpoint(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);
BNetEndpoint & operator=(const BNetEndpoint &);
const BNetAddress& LocalAddr();
const BNetAddress& RemoteAddr();
virtual ~BNetEndpoint();
int Socket() const;
/*
* It is important to call InitCheck() after creating an instance of this class.
*/
status_t InitCheck();
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);
/*
* When a BNetEndpoint is archived, it saves various state information
* which will allow reinstantiation later. For example, if a BNetEndpoint
* that is connected to a remote FTP server is archived, when the archive
* is later instantiated the connection to the FTP server will be reopened
* automatically.
*/
virtual status_t Archive(BMessage *into, bool deep = true) const;
static BArchivable * Instantiate(BMessage *archive);
int Error() const;
char* ErrorStr() const;
/*
* BNetEndpoint::SetProtocol()
*
* allows the protocol type to be changed from stream
* to datagram and vice-versa. The current connection (if any) is closed and
* the BNetEndpoint's state is reset.
*
* Returns B_OK if successful, B_ERROR otherwise.
*/
status_t SetProtocol(int proto);
virtual int32 Send(const void* buffer, size_t size, int flags = 0);
virtual int32 Send(BNetBuffer& buffer, int flags = 0);
/*
* These functions allow various options to be set for data communications.
* The first allows any option to be set; the latter two turn nonblocking
* I/O on or off, and toggle reuseaddr respectively. The default is for
* *blocking* I/O and for reuseaddr to be OFF.
*
* Returns 0 if successful, -1 otherwise.
*/
int SetOption(int32 opt, int32 lev, const void *data, unsigned int datasize);
int SetNonBlocking(bool on = true);
int SetReuseAddr(bool on = true);
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);
/*
* LocalAddr() returns a BNetAddress corresponding to the local address used by this
* BNetEndpoint. RemoteAddr() returns a BNetAddress corresponding to the address of
* the remote peer we are connected to, if using a connected stream protocol.
*/
const BNetAddress & LocalAddr();
const BNetAddress & RemoteAddr();
/*
* BNetEndpoint::Socket() returns the actual socket used for data communications.
*/
int Socket() const;
/*
* BNetEndpoint::Close()
*
* Close the current BNetEndpoint, terminating any existing connection (if any)
* and discarding unread data.
*/
void SetTimeout(bigtime_t usec);
virtual void Close();
/*
* BNetEndpoint::Bind()
*
* Bind this BNetEndpoint to a local address. Calling bind() without specifying
* a BNetAddress or port number binds to a random local port. The actual port
* bound to can be determined by a subsequent call to BNetEndpoint::LocalAddr().
*
* Returns B_OK if successful, B_ERROR otherwise.
*/
virtual status_t Bind(const BNetAddress &addr);
virtual status_t Bind(int port = 0);
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);
/*
* BNetEndpoint::Connect()
*
* Connect this BNetEndpoint to a remote address. The first version takes
* a BNetAddress already set to the remote address as an argument; the other
* one internally constructs a BNetAddress from the passed-in hostname and port
* number.
*
* Returns B_OK if successful, B_ERROR otherwise.
*/
virtual status_t Connect(const BNetAddress &addr);
virtual status_t Connect(const char *addr, int port);
/*
* BNetEndpoint::Listen()
*
* Specify the number of pending incoming connection attemps to queue.
* This is the number of connection requests that will be allowed in between
* calls to BNetEndpoint::accept(). When this number is exceeded, new
* connection attempts are refused until BNetEndpoint::accept() is called.
*
* Returns B_OK if successful, B_ERROR otherwise.
*/
virtual status_t Listen(int backlog = 5);
/*
* BNetEndpoint::Accept()
*
* Accepts new connections to a bound stream protocol BNetEndpoint.
* Blocks for timeout milleseconds (defaults to forever) waiting for
* new connections. Returns a BNetEndpoint with the same characteristics
* as the one calling BNetEndpoint::Accept(), the new one representing the new
* connection. This returned BNetEndpoint is ready for communication and
* must be deleted at a later time using delete.
*/
virtual BNetEndpoint *Accept(int32 timeout = -1);
virtual bool IsDataPending(bigtime_t timeout = 0);
/*
* BNetEndpoint::Error() will return the integer error code (set by the OS)
* for the last send/recv error. Likewise, BNetEndpoint::ErrorStr() returns
* a string describing the error.
*/
int Error() const;
char *ErrorStr() const;
private:
virtual void _ReservedBNetEndpointFBCCruft1();
virtual void _ReservedBNetEndpointFBCCruft2();
virtual void _ReservedBNetEndpointFBCCruft3();
virtual void _ReservedBNetEndpointFBCCruft4();
virtual void _ReservedBNetEndpointFBCCruft5();
virtual void _ReservedBNetEndpointFBCCruft6();
/*
* BNetEndpoint::Send()
*
* Send data to the remote end of the connection. If not connected, fails.
* If using a datagram protocol, fails unless BNetEndpoint::Connect()
* has been called, which caches the address we are sending to. The first
* version sends an arbitrary buffer of size size; the second sends the
* contents of a BNetBuffer. Both return the number of bytes actually
* sent, or -1 on failure.
*/
virtual int32 Send(const void *buf, size_t size, int flags = 0);
virtual int32 Send(BNetBuffer &pack, int flags = 0);
status_t fInit;
int fSocket;
bigtime_t fTimeout;
int fLastError;
BNetAddress fAddr;
BNetAddress fPeer;
/*
* BNetEndpoint::SendTo()
*
* Send data to the address specified by the passed-in BNetAddress object.
* Fails if not using a datagram protocol. The first version sends
* an arbitrary buffer of size size; the second sends the contents of a
* BNetBuffer. Both return the number of bytes actually sent,
* and return -1 on failure.
*/
virtual int32 SendTo(const void *buf, size_t size, const BNetAddress &to, int flags = 0);
virtual int32 SendTo(BNetBuffer &pack, const BNetAddress &to, int flags = 0);
/*
* BNetEndpoint::SetTimeout()
*
* Sets an optional timeout (in microseconds) for calls to BNetEndpoint::Receive()
* and BNetEndpoint::ReceiveFrom(). Causes these calls to time out after the specified
* number of microseconds when in blocking mode.
*/
void SetTimeout(bigtime_t usec);
/*
* BNetEndpoint::Receive()
*
* Receive data pending on the BNetEndpoint's connection. If in the default
* blocking mode, blocks until data is available or a timeout (set by
* BNetEndpoint::SetTimeout). The first call receives into a preallocated buffer
* of the specified size; the second call receives (at most) size bytes into
* an BNetBuffer. The data is appended to the end of the BNetBuffer; this allows
* a BNetBuffer to be used in a loop to buffer incoming data read in chunks
* until a certain size is read. Both return the number of bytes actually
* received, and return -1 on error.
*/
virtual int32 Receive(void *buf, size_t size, int flags = 0);
virtual int32 Receive(BNetBuffer &pack, size_t size, int flags = 0);
/*
* BNetEndpoint::ReceiveFrom()
*
* Receive datagrams from an arbitrary source and fill in the passed-in BNetAddress
* with the address from whence the datagram came. As usual, both return the
* actual number of bytes read. In the BNetBuffer version, the data is appended
* to the end of the BNetBuffer; this allows a BNetBuffer to be used in a loop to
* buffer incoming data read in chunks until a certain amount is read.
*/
virtual int32 ReceiveFrom(void *buf, size_t size, BNetAddress &from, int flags = 0);
virtual int32 ReceiveFrom(BNetBuffer &pack, size_t size, BNetAddress &from, int flags = 0);
/*
* BNetEndpoint::IsDataPending()
*
* Returns true if there is data waiting to be received on this BNetEndpoint.
* Will block for usec_timeout microseconds if specified, waiting for data.
*/
virtual bool IsDataPending(bigtime_t usec_timeout = 0);
inline NLEndpoint *GetImpl() const;
protected:
status_t m_init;
private:
virtual void _ReservedBNetEndpointFBCCruft1();
virtual void _ReservedBNetEndpointFBCCruft2();
virtual void _ReservedBNetEndpointFBCCruft3();
virtual void _ReservedBNetEndpointFBCCruft4();
virtual void _ReservedBNetEndpointFBCCruft5();
virtual void _ReservedBNetEndpointFBCCruft6();
int m_socket;
bigtime_t m_timeout;
int m_last_error;
BNetAddress m_addr;
BNetAddress m_peer;
BNetAddress m_conaddr;
int32 __ReservedBNetEndpointFBCCruftData[6];
int32 _reserved[18];
};
inline NLEndpoint *BNetEndpoint::GetImpl() const
{
return NULL; // No Nettle backward compatibility
}
#endif // _NETENDPOINT_H
#endif // H_NETENDPOINT
+15
View File
@@ -0,0 +1,15 @@
/*
* Copyright 2006, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef NET_R5_COMPATIBILITY_H
#define NET_R5_COMPATIBILITY_H
// TODO: judging from R5 headers, this is all wrong, though (this has been taken from
// our old socket header) - we'll need to test this later on!
// Also, more problematic is that IPPROTO_* constants also don't seem to be compatible, too
#define R5_SOCK_DGRAM 10
#define R5_SOCK_STREAM 11
#define R5_SOCK_RAW 12
#endif // NET_R5_COMPATIBILITY_H