This is recv.c in view mode; [Download] [Up]
#include "pthread_socket.h" #include "pthread_io_delay.h" extern void fd_init( void ); extern pthread_once_t io_initialized; static inline _syscall2(long,socketcall,int,call,unsigned long *,args); static int syscall_recv( int fd, void *buf, int len, unsigned int flags) { unsigned long args[4]; int ret; args[0] = (unsigned long) fd; args[1] = (unsigned long) buf; args[2] = (unsigned long) len; args[3] = (unsigned long) flags; LOCK_ON ret = socketcall( SYS_RECV, args ); LOCK_OFF return( ret ); } /*-------------------------------------------------------------------------- * @@ R E C V *-------------------------------------------------------------------------- * The recv function behaves in all respects like the * BSD accept() function except that only the calling thread is blocked. */ int recv( int fd, void *buf, int len, unsigned int flags ) { int ret, err, st; st = pthread_once( &io_initialized, fd_init ); if( st != SUCCESS ) return( NOTOK ); if( nonblock_is_set( fd )) { ret = syscall_recv( fd, buf, len, flags ); RETURN( ret ); } set_fd_nonblock( fd ); while((ret = syscall_recv( fd, buf, len, flags )) < OK ) { (void) pthread_get_errno_np( NULL, &err ); if( err != EWOULDBLOCK ) break; pthread_delay_np( &delay_interval ); } clear_fd_nonblock( fd ); return( ret ); }
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.