Class Endpoint

Inheritance Relationships

Derived Type

Class Documentation

class Endpoint

Base interface for all network endpoints.

Subclassed by gpa::network::NamedPipeEndpoint

Public Functions

virtual ~Endpoint()
virtual bool WaitRead(uint64_t readLengthInBytes) = 0

Asynchronously read a prescribed number of bytes from the endpoint into a provided byte buffer.

Parameters

readLengthInBytes -- Number of bytes to read; allocates internal buffer for async read of size readLengthInBytes

Returns

true if waiting; false if error (likely pipe invalid for some reason)

virtual bool IsWaitingOnRead() = 0

Whether we have an active WaitRead waiting on input from the pipe.

Returns

True if currently waiting on read operation to complete.

virtual uint64_t Read(void *destBuffer, uint64_t readLengthInBytes) = 0

Read a prescribed number of bytes from the endpoint into a provided byte buffer.

Parameters
  • destBuffer -- Buffer to receive byte data from the endpoint.

  • readLengthInBytes -- Number of bytes to read; this number should not exceed the size of the destination buffer in bytes.

Returns

Number of bytes actually read.

virtual uint64_t Write(void const *srcBuffer, uint64_t writeLengthInBytes) = 0

Write a prescribed number of bytes to the endpoint from a provided byte buffer.

Parameters
  • srcBuffer -- Buffer containing byte data to write to the endpoint.

  • writeLengthInBytes -- Number of bytes to write; this number should not exceed the size of the source buffer in bytes.

Returns

Number of bytes actually written.

virtual Endpoint *Accept(uint64_t timeoutMS) = 0

Accept an incoming connection request. This is a blocking operation.

Parameters

timeoutMS -- Number of milliseconds to wait for a connection attempt. This number can be zero for "no waiting/blocking", in which case the method will return immediately.

Returns

If a pending connection attempt was accepted, a pointer to a new Endpoint that corresponds to the newly established connection with the remote client. If this method returns nullptr, then the timeout expired. If any other error occured, this method throws NetworkException.

virtual void Shutdown() = 0

Close the socket and clean up the endpoint. This will produce a "connection reset" error on the connected peer (server or client endpoint).

virtual uint64_t Handle() const = 0

Obtain the file descriptor corresponding to the network endpoint.

This is typically useful in server applications where for efficiency reasons, the server must wait for activity on multiple endpoints at once, using low-level API calls that deal with integer file descriptors.

Returns

The current value of the socket endpoint's file descriptor (default: -1)

virtual uint64_t EventHandle() const = 0

Get Handle for Event tracking on endpoint.

Returns

The current value of the socket endpoint's event handle (default: -1)

virtual bool IsEndpointBroken() const = 0

Whether or not endpoint has encountered handled fatal error. If function returns true, but has encountered a novel fatal error code, add that and any necessary handling.

Returns

False if pipe hasn't encountered known fatal error in operations.