TutSocketAccept


Name

TutSocketAccept — accept a socket connection from client

Synopsis

T_INT4 TutSocketAccept(server_fd) 
T_INT4 server_fd; 

Arguments

server_fd — server side of socket

Return Values

New socket file descriptor to client if successful, -1 otherwise.

Diagnostics

If TutSocketAccept fails, it returns -1 and sets the global SmartSockets error number to one of:

Description

TutSocketAccept is a convenience function that provides a simplified interface to the accept function. TutSocketAccept accepts a socket connection from a new client and returns a new socket file descriptor that is connected to that client. The server_fd socket is left open to accept more clients. TutSocketAccept blocks if accept blocks. (Use TutSocketCheck to check if a new client has connected.)

Caution

None

See Also

TutSocketCheck

Examples

This code uses TutSocketCheck to wait for up to 10 seconds for a new client to connect to a server socket, then accepts the new client with TutSocketAccept:

if (!TutSocketCheck(server_fd, T_IO_CHECK_READ, 10.0)) { 
  /* error */ 
}  
else { 
  client_fd = TutSocketAccept(server_fd); 
  if (client_fd == -1) { 
    /* error */ 
  } 
} 

TIBCO SmartSockets™ Utilities
Software Release 6.8, July 2006
Copyright © TIBCO Software Inc. All rights reserved
www.tibco.com