Audiovox P965 Datový list Strana 220

  • 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 219
API in C
217
* Returns a socket descriptor
********************************************************************/
int apiConnect(char *szIPaddr, int iPort)
{
int fdSock;
struct sockaddr_in address;
int iConnectResult;
int iLen;
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;
}
// determine endianness of this machine
// iLittleEndian will be set to 1 if we are
// on a little endian machine...otherwise
// we are assumed to be on a big endian processor
iLittleEndian = isLittleEndian();
return fdSock;
}
/********************************************************************
* Disconnect from API
* Close the API socket
********************************************************************/
void apiDisconnect(int fdSock)
{
Zobrazit stránku 219
1 2 ... 215 216 217 218 219 220 221 222 223 224 225 ... 279 280

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

Žádné komentáře