Remote Control Basics
R&S
®
SMBV100A
410
Operating Manual 1407.6062.32 ─ 08
currentHostName = "";
currentPort = 0;
currentHostInfo = NULL;
clientIsConnected = false;
printf("can't create socket\n" );
}
serverAddress.sin_family = currentHostInfo->h_addrtype;
serverAddress.sin_port = htons( currentPort );
memcpy( (char *) &serverAddress.sin_addr.s_addr,
currentHostInfo->h_addr_list[0], currentHostInfo->h_length );
if( connect( currentSocketDescr, ( struct sockaddr *) &serverAddress,
sizeof( serverAddress ) ) < 0 )
{
throw string("can't connect server\n" );
}
clientIsConnected = true;
}
void TcpClient::disconnect( )
{
if( clientIsConnected )
{
close( currentSocketDescr );
}
currentSocketDescr = 0;
currentHostName = "";
currentPort = 0;
currentHostInfo = NULL;
clientIsConnected = false;
}
void TcpClient::transmit( string &txString )
{
if( !clientIsConnected )
{
throw string("connection must be established before any data can be sent\n");
}
char * transmitBuffer = new char[txString.length() +1];
memcpy( transmitBuffer, txString.c_str(), txString.length() );
transmitBuffer[txString.length()] = '\n'; //newline is needed!
if( send( currentSocketDescr, transmitBuffer, txString.length() + 1, 0 ) < 0 )
{
throw string("can't transmit data\n");
}
delete [] transmitBuffer;
}
void TcpClient::receive( string &rxString )
{
if( !clientIsConnected )
{
throw string("connection must be established before any data can be received\n");
}
Starting a Remote Control Session
Summary of Contents for SMBV100A
Page 31: ......