to bernie: more on mixedlib.e and other stuff

new topic     » topic index » view thread      » older message » newer message

Hey there Bernie,

 I have more questions about mixedlib.e and the new "AssociatePtr( )" routine
you coded in responce to some of my earlier problems.

 I have wrapped the accept( ) function from C. This wrapper seems to work fine
on the surface eg. connections are accepted and i can send and recv through the
socket. The problem im having occurs randomly from the first to the ????
accept( ) attempt on a server using my wrapped accept( ). Mixedlib pops me
back with an error stating:

GETS FUNCTION FAILED !
Member sin_family does not exists

 Now i know that this *would* be normal if that member *did NOT* exist all the
time but this error randomly occurs. I use your "AssociatePtr( )" routine just
like you advised but it still messes up consistently but only after a
random number of connections.

 Here is the code i have so far for accept( ). I think that im also doing
someting wrong in initializing the sockaddr_in_ptr pointer.

-- include mixedlib.e

global
function accept( int sd )
  int status
  pointer sockaddr_in_ptr, len_ptr
  sequence return_seq
  
  sockaddr_in_ptr = allocate( 16 ) -- the size of a sockaddr_in struct
  len_ptr = get_pointer( sizeof( sockaddr_in_ptr ) )
  
  status = c_func( accept_, { sd, sockaddr_in_ptr, len_ptr } )
  
  if ( status > 0 and len_ptr != 0 ) then  
    AssociatePtr( sockaddr_in_ptr, get_sockaddr_in_seq( ), HIGH )
                        
    return_seq = { { Gets( sockaddr_in_ptr, "sin_family" ), -- error here
                     Gets( sockaddr_in_ptr, "sin_port" ),
                     Gets( sockaddr_in_ptr, "s_addr" ) }, status }
    
    free( len_ptr )
    free( sockaddr_in_ptr )
    return return_seq
  else
    free( len_ptr )
    free( sockaddr_in_ptr )
    return -1
  end if
  
end function

 get_sockaddr_in_seq( ) just returns a "struc" copatiable sequence.
I slightly modified AssociatePtr in how its invoked but not in its function.

 One other thing, the s_addr member of sockaddr_in_ptr always returns some
gooffy IP address and the last two dot delimited numbers (after conversion
using inet_ntoa) are always ?.?.17.8 no matter who connects, me or a friend.
I think this all has to do with the way that im initializing sockaddr_in_ptr
but ive tried many different ways and it never seems to make a difference.

 Any help on either of these two questions would greatly help. If you need
anymore info that i have not including i will be more than willing to mail it
away.

-- 
evil, corruption and bad taste
^[cense]

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu