Stellarium  26.3
Public Member Functions
TcpConnection Class Reference

Outgoing TCP/IP client connection to a device that speaks an ASCII telescope protocol (such as a Meade LX200 exposed over a network bridge). More...

#include <TcpConnection.hpp>

Public Member Functions

 TcpConnection (Server &server, const char *host, int port)
 
- Public Member Functions inherited from Connection
 Connection (Server &server, SOCKET fd)
 
long long int getServerMinusClientTime (void) const
 
- Public Member Functions inherited from Socket
void hangup ()
 
virtual bool isClosed () const
 

Additional Inherited Members

- Protected Member Functions inherited from Connection
void performReading (void)
 Receives data from a TCP/IP connection and stores it in the read buffer.
 
void performWriting (void)
 Sends the contents of the write buffer over a TCP/IP connection.
 
void prepareSelectFds (fd_set &read_fds, fd_set &write_fds, int &fd_max) override
 
- Protected Member Functions inherited from Socket
 Socket (Server &server, SOCKET fd)
 
int readNonblocking (void *buf, int count)
 
int writeNonblocking (const void *buf, int count)
 
- Protected Attributes inherited from Connection
char read_buff [120]
 
char * read_buff_end
 
char write_buff [120]
 
char * write_buff_end
 
- Protected Attributes inherited from Socket
Server & server
 
SOCKET fd
 

Detailed Description

Outgoing TCP/IP client connection to a device that speaks an ASCII telescope protocol (such as a Meade LX200 exposed over a network bridge).

Unlike Connection, whose constructor wraps an already-accepted socket, TcpConnection actively resolves host and connects to port. Once connected it reuses all of Connection's cross-platform, select()-based reading and writing. The socket is switched to non-blocking mode, but the initial connection attempt is performed synchronously (with a timeout) so that isClosed() reflects the real connection state right after construction, mirroring the behaviour of SerialPort.

Constructor & Destructor Documentation

◆ TcpConnection()

TcpConnection::TcpConnection ( Server &  server,
const char *  host,
int  port 
)
Parameters
hosthost name or IPv4/IPv6 address of the telescope.
portTCP port the telescope is listening on.