Audiovox P965 Arkusz Danych Strona 220

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 280
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 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)
{
Przeglądanie stron 219
1 2 ... 215 216 217 218 219 220 221 222 223 224 225 ... 279 280

Komentarze do niniejszej Instrukcji

Brak uwag