Audiovox P965 Datový list Strana 61

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 280
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 60
API in C using winsock
58
// Updated 28 August 2011 by hel
#include <stdio.h>
#include <winsock2.h>
#pragma comment(lib, "ws2_32.lib")
#include <windows.h>
#include <string.h>
#include <stdlib.h>
#include "md5.h"
#include "mikrotik-api.h"
/********************************************************************
* Connect to API
* Returns a socket descriptor
********************************************************************/
int apiConnect(char *szIPaddr, int iPort)
{
int fdSock;
struct sockaddr_in address;
int iConnectResult;
int iLen;
WORD versionWanted = MAKEWORD(1,1);
WSADATA wsaData;
WSAStartup(versionWanted, &wsaData);
fdSock = socket(AF_INET, SOCK_STREAM, 0);
address.sin_family = AF_INET;
address.sin_addr.s_addr = inet_addr(szIPaddr);
address.sin_port = htons(iPort);
iLen = sizeof(address);
DEBUG ? printf("Connecting to %s\n", szIPaddr) : 0;
iConnectResult = connect(fdSock, (struct sockaddr *)&address, iLen);
if(iConnectResult==-1)
{
perror ("Connection problem");
exit(1);
}
else
{
DEBUG ? printf("Successfully connected to %s\n", szIPaddr) : 0;
Zobrazit stránku 60
1 2 ... 56 57 58 59 60 61 62 63 64 65 66 ... 279 280

Komentáře k této Příručce

Žádné komentáře