Remote Control Basics
R&S
®
SMU200A
463Operating Manual 1007.9845.32 ─ 15
TcpClient.h
#include <string>
using namespace std;
//defines structs for socket handling
#ifndef LINUX
#include "Winsock2.h"
#else
#include <netinet/in.h>
#endif
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
#ifdef LINUX
#include <netdb.h>
#include <unistd.h>
#endif
#include "TcpClient.h"
TcpClient::TcpClient()
: currentHostName( "" )
, currentPort( 0 )
, currentSocketDescr( 0 )
, serverAddress ( )
, currentHostInfo( NULL )
, clientIsConnected( false )
, receiveBufferSize( 1024 )
Starting a Remote Control Session