WLAN UDP -specific implementation
Public Methods
-
CUDPConnection(const std::string& aIface)
- Default constructor.
-
~CUDPConnection()
- Default destructor.
-
void Close()
- Explicitly closes the socket.
-
int Write(const void* aOutBuf, int aLength, int aPort, const std::string& aAddress, const std::string& aMode)
- Sends data to the other end of the connection.
-
int Read(void* aInBuf, int aLength)
- Reads data from an open connection.
-
const std::string& GetRemoteAddress()
- Returns connection's remote address.
-
int GetFd()
- Returns connection's file descriptor.
-
bool Listen(int aPort, const std::string& aMode)
- Sets the connection to the listening state.
-
bool IsListening()
- Tells if the connection is listening.
-
bool HasData()
- Tells if the connection has data waiting
Documentation
WLAN UDP -specific implementation
This class offers a unified interface through what WLAN can be used
like any other transport medium in the PeerHood environment.
CUDPConnection(const std::string& aIface)
-
Default constructor, sets the initial vatiables to their default values
and creates a new WLAN socket.
- Returns:
- none
~CUDPConnection()
-
Default destructor, deletes allocated variables
- Returns:
- none
void Close()
-
Explicitly closes the socket without any additional state checking,
i.e. this function will execute even if there's no existing connection.
This function is used by the PeerHood engine to ensure that no file
descriptors are leaked.
- Returns:
- none
int Write(const void* aOutBuf, int aLength, int aPort, const std::string& aAddress, const std::string& aMode)
-
Sends data to the other end of the connection. Note that this
function is not endianess-safe.
- Parameters:
- aOutBuf - Buffer containing the data that should be written.
aLength - The number of bytes to be written.
aPort - Destination port
aMode - Mode for sending. This can be "bcast" for broadcasting
and "ucast" for unicasting
- Returns:
- the number of bytes written or -1 in the case of an error
int Read(void* aInBuf, int aLength)
-
Reads data from an open connection. Just like
<code>Read</code> this function is not endianess-safe so it should be
treated more like a standard Posix sequential socket.
- Parameters:
- aInBuf - Buffer where the data is read to.
aLength - The number of bytes that should be read.
- Returns:
- the number of bytes read or -1 in the case of an error
const std::string& GetRemoteAddress()
-
Returns connection's remote address. Note that the existence of the
address doesn't mean that there's a connection established.
- Returns:
- connection's remote address
int GetFd()
-
Returns connection's file descriptor. Other classes can have a direct
access to the connection's socket (or similar entity) via this function's
return value.
- Returns:
- connection's file descriptor or -1 if one isn't available
bool Listen(int aPort, const std::string& aMode)
-
Sets the connection to the listening state. This function must be
called before any incoming connections targeted to this object can be
accepted.
- Parameters:
- aPort - The port that should be listened
aMode - Listen mode. This can be "bcast" broadcast
or "ucast" for unicast mode.
- Returns:
- true if successfull
bool IsListening()
-
Tells if the connection is in the listening state or not.
- Returns:
- true if the connection is in the listening state
bool HasData()
-
Waits for the connection to have data to read, and returns true
- Returns:
- true if the data is ready
- This class has no child classes.
Alphabetic index HTML hierarchy of classes or Java
This page was generated with the help of DOC++.