12 October 2019

Library

  • gloox C++

  • libstrophe C

  • QXmpp C++

  • Swiften C++

Linux Programmierung

#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>

bool TCPConnection::connectSocket() {
        int socketfd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);   // (1)
        struct sockaddr_in serv_addr, cli_addr;
        serv_addr.sin_family = AF_INET;
        struct hostent* server =  gethostbyname(m_hostname.c_str());
        bzero((char *) &serv_addr, sizeof(serv_addr));
        serv_addr.sin_family = AF_INET;
        bcopy((char *)server->h_addr,
        (char *)&serv_addr.sin_addr.s_addr, server->h_length);
        serv_addr.sin_port = htons(std::stoi(m_port));
        connect(socketfd, (struct sockaddr *) &serv_addr,sizeof(serv_addr));
        m_socketfd = socketfd;
        return true;
}
  1. Open Socket