Erwtisi gia socket programming
Giorgos Keramidas
keramidi at otenet.gr
Thu Apr 12 00:39:36 EEST 2001
On Wed, Apr 11, 2001 at 11:51:07PM +0300, Michalis Kabrianis wrote:
>
> > Na rwthsw ki egw kati panw se auto. H inet_ntoa bazei to apotelesma se
> > static buffer. Yparxei kapoia etoimh analogh function pou einai thread
> > safe?
>
> Seira mou na min katalabw.
> I inet_ntoa bazei to apotelesma se char* to opoio pragmati mpainei se
> statically allocated buffer, alla ti se empodizei na to kaneis assign se
> mia diki sou metabliti?
Oh, ennoeis me kati opws to parakato code fragment ?
struct in_addr *addr;
char *
ptr = strdup(inet_ntoa(*addr));
Thread / time diagram me antiparadeigma included below:
Thread 1 Thread 2
| |
| |
| enter inet_ntoa |
| | enter inet_ntoa
| write some data to static buffer |
| | write some other data in static buffer
| return from inet_ntoa |
| enter strdup |
| | return from inet_ntoa
| | enter strdup
| |
| |
BOOM!
--giorgos
More information about the Linux-greek-users
mailing list