Audiovox P965 Arkusz Danych Strona 123

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 280
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 122
API In CPP
120
Mikrotik API source file (MikrotikAPI.cpp)
#include "MikrotikAPI.h"
using namespace std;
MikrotikAPI::MikrotikAPI(const string &strIpAddress, const string &strUsername,
const string &strPassword, int port)
{
Connect(strIpAddress, port);
if(fdSock != -1) {
// attempt login
int loginResult = Login(strUsername, strPassword);
if (!loginResult) {
throw NOLOGIN;
Disconnect();
printf("Invalid username or password.\n");
} else {
printf("Logged in successfully.\n");
}
} else {
throw NOCONNECT;
}
}
MikrotikAPI::~MikrotikAPI()
{
if(fdSock != -1)
Disconnect();
}
/********************************************************************
* Connect to API
* Returns a socket descriptor
********************************************************************/
void MikrotikAPI::Connect(const string &strIpAddress, int port)
{
struct sockaddr_in address;
int connectResult;
int addressSize;
fdSock = socket(AF_INET, SOCK_STREAM, 0);
address.sin_family = AF_INET;
address.sin_addr.s_addr = inet_addr(strIpAddress.c_str());
Przeglądanie stron 122
1 2 ... 118 119 120 121 122 123 124 125 126 127 128 ... 279 280

Komentarze do niniejszej Instrukcji

Brak uwag