EasyManua.ls Logo

Rohde & Schwarz SGS100A - B Telnet Program Examples

Rohde & Schwarz SGS100A
324 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Telnet program examples
R&S
®
SGS100A
312User Manual 1173.9105.02 ─ 12
B Telnet program examples
The following program example shows a simple TcpClient class that is intended to
explain on how to get started with programming of sockets.
The example sets up a socket communication to R&S SGS and opens a simple user
interface, very similar to the telnet, which allows input of commands. To enable real
automation, further development of the program is required.
TcpClient.h
#include <string>
//defines structs for socket handling
#include <netinet/in.h>
using namespace std;
typedef struct sockaddr_in SockAddrStruct;
typedef struct hostent HostInfoStruct;
class TcpClient
{
public:
TcpClient();
~TcpClient();
void connectToServer( string &hostname, int port );
void disconnect( );
void transmit( string &txString );
void receive( string &rxString );
string getCurrentHostName( ) const;
int getCurrentPort( ) const;
private:
string currentHostName;
int currentPort;
int currentSocketDescr;
SockAddrStruct serverAddress;
HostInfoStruct * currentHostInfo;
bool clientIsConnected;
int receiveBufferSize;
};
TcpClient.cpp
#include <string>
//defines structs for socket handling
#include <netinet/in.h>
using namespace std;
typedef struct sockaddr_in SockAddrStruct;
typedef struct hostent HostInfoStruct;
class TcpClient
{
public:
TcpClient();

Table of Contents