🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.programming
3 messages
3 total messages Started by pul... Krzysztof Pulapa Wed, 14 Feb 1996 00:00
ciekawostka ....
#317
Author: pul... Krzysztof Pulapa
Date: Wed, 14 Feb 1996 00:00
29 lines
1368 bytes
Trafilem ostatnio na nastepny ciekawy numer jaki zaoferowal mi kompilator .
Stracilem przez to caly dzien ...

Mialem taka procedurke :

1)  unsigned long ii;
2)  struct hostent *pp;
3)  ii=inet_addr(hostname);
4)  pp=gethostbyaddr((char *)&ii, INADDRSZ, AF_INET);
5)  if (pp) return(call_socket(pp->h_name,port)); else return(-1);

Wbrew pozorom wcale to nie dzialalo , znaczy sie dzialalo na SunOS a na
Linuxie juz nie ... w koncu doprowadzony do pacji zmienilem to 
 na cos takiego :

1)  unsigned long ii;
2)  struct hostent *pp;
3)  char hname[MAXHOSTNAMELEN];
4)  ii=inet_addr(hostname);
5)  pp=gethostbyaddr((char *)&ii, INADDRSZ, AF_INET);
6)  strcpy(hname,pp->h_name);
7)  if (pp) return(call_socket(hname,port)); else return(-1);

I ruszylo ... ale nie bardzo wiem do tej pory dlaczego ;-)

--
Pulapa Krzysztof   ,  Politechnika Krakowska
  E-mail:   pul...@edison.pk.edu.pl , ji...@avalon.wbc.lublin.pl
  URL   :   http://avalon.wbc.lublin.pl/~jimi , on IRC : Jimi
Re: ciekawostka ....
#318
Author: le... Lech Szychowski
Date: Wed, 14 Feb 1996 00:00
18 lines
1129 bytes
Krzysztof Pulapa (pul...@edison.pk.edu.pl) wrote:

: 5)  pp=gethostbyaddr((char *)&ii, INADDRSZ, AF_INET);
: 6)  strcpy(hname,pp->h_name);
: 7)  if (pp) return(call_socket(hname,port)); else return(-1);

To nie wyglada na bezpieczna/sensowna kolejnosc - jesli (5) zwroci NULL,
to (6) sie wywali, wiec test (7) mozna sobie zapewne darowac.

--

	Leszek.

+============================================================================+
| le...@pse.pl 2:480/33.7                  - REAL programmers use INTEGERS - |
| My personal opinions are just mine.                                        |
| If there is anyone I speak for, then most likely it's me.                  |
+============================================================================+
Re: ciekawostka ....
#319
Author: k... Krzysztof Halasa
Date: Fri, 16 Feb 1996 00:00
32 lines
1453 bytes
Krzysztof Pulapa (pul...@edison.pk.edu.pl) wrote:

> Mialem taka procedurke :

> 1)  unsigned long ii;
> 2)  struct hostent *pp;
> 3)  ii=inet_addr(hostname);
> 4)  pp=gethostbyaddr((char *)&ii, INADDRSZ, AF_INET);
> 5)  if (pp) return(call_socket(pp->h_name,port)); else return(-1);

> Wbrew pozorom wcale to nie dzialalo , znaczy sie dzialalo na SunOS a na
> Linuxie juz nie ...

z "man gethostbyaddr":

       All information is contained in a static area so  it  must
       be copied if it is to be saved.

Prawdopodobnie call_socket zmienialo zawartosc pp (zmiennej statycznej
w clib), np. przez wykonanie innej funkcji uzywajacej tej samej zmiennej,
przed wykorzystaniem oryginalnej zawartosci.

Greetings,
                                                KHC

--------------------------------------------------------------------
Krzysztof Halasa
Network Administrator of The Palace of Youth in Warsaw

Palac Mlodziezy                      Internet: k...@pm.waw.pl
ul. Swietokrzyska                     Fidonet: KHC, 2:480/40
00-901 Warsaw, Poland
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads