Purpose
Creates a Transmission Control Protocol/Internet Protocol (TCP/IP) service transport handle.
Library
C Library (libc.a)
Syntax
Description
The svctcp_create subroutine creates a Remote Procedure Call (RPC) service transport handle based on TCP/IP and returns a pointer to it.
Since TCP/IP remote procedure calls use buffered I/O, users can set the size of the send and receive buffers with the sendsz and recvsz parameters, respectively. If the size of either buffer is set to a value of 0, the svctcp_create subroutine picks suitable default values.
Parameters
| Item | Description | 
|---|---|
| sock | Specifies the socket associated with the transport. If the value of the sock parameter is RPC_ANYSOCK, the svctcp_create subroutine creates a new socket. The service transport handle socket number is set to xprt->xp_sock. If the socket is not bound to a local TCP/IP port, then this routine binds the socket to an arbitrary port. Its port number is set to xprt->xp_port. | 
| sendsz | Specifies the size of the send buffer. | 
| recvsz | Specifies the size of the receive buffer. | 
Restrictions
In AIX® 5.2, the maximum number of open file descriptors that an RPC server can use has been set to 32767 so that compatibility can be maintained with RPC-server applications built on earlier releases of AIX.
Return Values
Upon successful completion, this subroutine returns a valid RPC service transport handle. If unsuccessful, it returns a value of null.
Purpose
Creates a Transmission Control Protocol/Internet Protocol (TCP/IP) service transport handle.
Library
Network Services Library (libnsl.a)
Syntax
#include <rpc/rpc.h>
 SVCXPRT *svctcp_create (fd, sendsz, recvsz)
int fd;
uint_t sendsz;
uint_t recvsz;
Description
The svctcp_create subroutine creates a Remote Procedure Call (RPC) service transport handle based on TCP/IP and returns a pointer to it.
Because TCP/IP remote procedure calls use buffered I/O, you can set the size of the send and receive buffers with the sendsz and recvsz parameters. If the size of either buffer is set to a value of 0, the svctcp_create subroutine picks suitable default values. The fd parameter specifies a file descriptor on a TCP transport. You can set the value of the fd parameter to RPC_ANYSOCK, so that the svctcp_create subroutine creates a new file descriptor on the TCP transport and binds the file descriptor to a port.
Use the svc_create subroutine instead of the svctcp_create subroutine. The svctcp_create subroutine is compatible only with earlier versions of AIX.
Parameters
| Item | Description | 
|---|---|
| fd | Specifies the file descriptor that is associated with the TCP transport. | 
| sendsz | Specifies the size of the send buffer. | 
| recvsz | Specifies the size of the receive buffer. | 
Return Values
| Item | Description | 
|---|---|
| a valid RPC service transport handle | successful | 
| a null value | unsuccessful | 
Examples
#include <rpc/rpc.h>
static void dispatch(struct svc_req *, SVCXPRT *);
int main()
{
  SVCXPRT    *svc=NULL;
  int     fd;
  uint_t     sendsz, recvsz; 
  int     protocol = IPPROTO_TCP;
  /* Set send and recieve buffer sizes to 0 so that they are set to 
   * default values when svctcp_create() is called    
   */
  sendsz = 0;
  recvsz = 0;
  /* Set the file descriptor to RPC_ANYFD */
  fd = RPC_ANYSOCK;
  svc = (SVCXPRT *) svctcp_create(fd, sendsz, recvsz);
  if(svc==NULL)
  {
    fprintf(stderr,"svctcp_create() failed");
    exit(1);
  }
  /* create association between program & version number and dispatch routine */
  if(svc_register(svc, prognum, versnum, dispatch, protocol) == 0)
  {
    fprintf(stderr,"svc_register() failed");
    exit(1);
  }
  
  /* Accept client requests */
  svc_run();
  return 1;
}
static void dispatch(rqstp, transp)    /* remote procedure */
  struct svc_req *rqstp;
  SVCXPRT        *transp;
{
  /* Dispatch Routine Code */
}