Home

News

Software

Bilder

Texte
  - Börse
  - Favoriten
    - Goddesses
  - Winsock
  - Diplomarbeit
    - Titel
    - Inhalt
    - Einleitung
    - Kapitel 2
      - Kapitel 2-1
      - Kapitel 2-2
      - Kapitel 2-3
    - Kapitel 3
      - Kapitel 3-1
      - Kapitel 3-2
      - Kapitel 3-3
    - Ausblick
    - Literatur
    - Anhang

Alles fliesst

Comics

Musik

Leben

Links

Sitemap

Admin


TV News bei
Quotenmeter

[ TEXT-INDEX][ WINSOCK-INDEX] [ Api-routines] [ Api] [ Dns] [ Error-reference] [ First-internet-client] [ Guided-tour] [ Http-client] [ Http-server] [ News-event-object] [ News-gethostbyaddr] [ Overview] [ Pop3-client] [ Port-numbers] [ Protocol-names] [ Simple-ftp-client] [ Smtp-client] [ Snmp] [ Sockets-programing] [ Tcpip-client] [ Tcpip-server]


News: Windows Sockets gethostbyaddr() doesn't work

(Adapted) Winsock-Sourcen von Daniel Schwamm (11.10.1996)

Aus "Heimat des Dilettantismus"
http://www.henrys.de/daniel/index.php?cmd=texte_winsock_news-gethostbyaddr.htm


Re: Windows Sockets' gethostbyaddr() doesn't work --------------------------------------------------------------------------- From kahn@lgk.com (Larry Kahn) Organization Dynamics Research Corp. Date Thu, 10 Oct 1996 01:55:40 GMT Newsgroups microsoft.public.win95.networking,comp.os.ms-windows.networking.tcp-ip Message-ID <a97cc$143728.6d@p6dnf.drcoffsite.com> References 1 --------------------------------------------------------------------------- In article <325B5AD9.1093@vtools.es>, jlanyo@vtools.es says... > >Hi all. >I have developed a DLL to cover IP net communications using Windows >Sockets. Up to date, I have not any problem, until I have try to use >gethostbyaddr() function. This always returns 0 and I'm not able to find >out what's going on. The error code returned by WSAGetLastError is 11004 >(Valid name, no data record of requested type...). I have tried to use >the async version of this function, and the result is the same. >I'm sure the parameters are well, a pointer to an address in network >byte order, its length (4 bytes), and PF_INET. > >Could somebody help me? >Thanks in advance. > > include <stdio.h> #include <stdlib.h> #include <winsock.h> void disp_help() { printf("\nGet host name program V 1.1 by L. Kahn (C) 1995\n"); printf("_______________________________________________\n\n"); printf("Syntax: ghostname hostname \n"); printf("WHERE: hostname is the name or ip address of a host.\n\n"); } void main(argc,argv) int argc; char **argv; { WORD wVersionrequired; WSADATA WSData; char remotename[80]; static struct sockaddr_in destination; static struct hostent *ptrhostentry; LPSTR plpstr; struct in_addr *pin_addr; int rval = 0; wVersionrequired = MAKEWORD(1,1); if (argc != 2) disp_help(); else { /* ok assume second arg is host name */ rval = WSAStartup(wVersionrequired, &WSData); if (rval != 0) { printf("Startup ERROR: could not find a usable a winsock DLL.\n"); fflush(stdout); exit(1); } if (LOBYTE(WSData.wVersion) != 1 || HIBYTE(WSData.wVersion) != 1) { printf("Startup ERROR: could not find a winsock DLL version 1.1 or newer.\n"); fflush(stdout); exit(1); } else { strcpy(remotename,argv[1]); memset(&destination,0,sizeof(struct sockaddr)); destination.sin_family=AF_INET; destination.sin_addr.s_addr = inet_addr(remotename); if(destination.sin_addr.s_addr ==INADDR_NONE) { ptrhostentry = gethostbyname(remotename); if (ptrhostentry == NULL) { printf("can't get entry for host name: %s\n",remotename); fflush(stdout); WSACleanup(); exit(1); } } else { ptrhostentry = gethostbyaddr((LPSTR)&destination.sin_addr.s_addr,4,PF_INET); if (ptrhostentry == NULL) { printf("can't get ip entry for host name: %s\n",remotename); fflush(stdout); WSACleanup(); exit(1); } } /* if we get here we have valid entry so do it */ memcpy(&destination.sin_addr,ptrhostentry->h_addr,ptrhostentry->h_length); printf("Translated Name is: %s\n",ptrhostentry->h_name); while((pin_addr=(struct in_addr *)*(ptrhostentry->h_addr_list))!=NULL) { printf("IP Address is : %s\n",inet_ntoa(*pin_addr)); ptrhostentry->h_addr_list++; } while((plpstr=(LPSTR)*(ptrhostentry->h_aliases))!=NULL) { printf("Alias: %s\n",plpstr); ptrhostentry->h_aliases++; } } /* end of ok startup */ } /* end of ok parameters */ printf("\n"); fflush(stdout); WSACleanup(); } /* end of main */ >-- >Jose Luis Anyonuevo | Visual Tools S.A. | Tel: +34 1 5352642 >Software Engineer | Video Surveillance | Fax: +34 1 5353695 > | Almansa 62 | >jlanyo@vtools.es | 28039 Madrid (SPAIN) | sales: nacho@vtools.es > -- _________________________________________________________________________ Larry Kahn __ __ __ __ Senior Software Engineer / \ / \ / \ / \ Dynamics Research Corp. ____________________/ __\/ __\/ __\/ __\_____________________________ ___________________/ /__/ /__/ /__/ /________________________________ kahn@lgk.com / / \ / \ / \ / \ \____ kahn@drcoffsite.com \_/ \_/ \_/ \_/ \ o \ \_____/--< (TALK: larry@ambra.drcoffsite.com) (FINGER: .site@ambra.drcoffsite.com for PGP public key) _________________________________________________________________________

| Home | News | Software | Bilder | Texte | Börse | Favoriten | Goddesses | Winsock | Diplomarbeit | Titel | Inhalt | Einleitung | Kapitel 2 | Kapitel 2-1 | Kapitel 2-2 | Kapitel 2-3 | Kapitel 3 | Kapitel 3-1 | Kapitel 3-2 | Kapitel 3-3 | Ausblick | Literatur | Anhang | Alles fliesst | Comics | Musik | Leben | Links | Sitemap | Admin |

© by DanPHPEd - Letzte Änderung: 29. März 2009