TCP Buckets: 

=============
| srvip.h   |
=============

typedef struct tcpbckt 
{
  ...
  SINT32 siz;               /**< bucket target size (size in bytes of 'this' contract   */
  int len;                  /**< bucket buffer length (size in bytes of the contract buffer) */
  int clrlen;               /**< collector buffer length (size in bytes of the collection buffer) */
  ...
} TCPBCKT;

=============
| client.c  |
=============
SOCKET getTcpConTblSocket(ConTblEntry *c,int inetProtocol)
...
//TCP_BUFFER_SIZE = 16 KBytes  (the TCP 'chunck' size) 
    ...
#   ifdef MULTITHREADED
    clrlen = TCP_BUFFER_SIZE;  
	// => the size of the bucket collector length 'clrbuf' (fixed)
	// incoming bytes collected here and copied into the contract buffer 'buf'
	
    buflen = c->sizeOut * fmtsizeof(c->formatOut) + TCP_BUFFER_SIZE; 
	// => the size of the bucket conract buffer 'buf' in bytes 
	// must be large enough to hold a complete contract with payload
	// will be re-allocated if necessary
    
	if (inetProtocol&(STREAM|STREAM6)) port = gtStrmPort; 
#   endif
    if (connectTCP(c,port,inetProtocol) == 0)
    { /* success */
      msglog(0,"new %s connection to %.256s",lnkp,lnkn);
      if ((bckt=getBucket(c->tcpSck,buflen,clrlen,inetProtocol,c->tineProtocol,CLN_REQ_)) != NULL)
    ...
	
=============
| clnip.c :
=============

int processTCPDataStream(TCPBCKT **pbckt,int nread)
{
  // handles TCP/IP responses from server ...
}

=============
| srvip.c : |
=============

ClnHdr *getConsumerIPAddress(SOCKET sck,int inetProtocol)
{
  // handles incoming client requests (all protocols)
  ...
  if (inetProtocol & (TCP|PIPE|STREAM|TCP6|STREAM6))
  { // TCP/IP branch 
    collects directly into the contract buffer 'buf'
  }
  
}
called from 

void AcceptIP(struct timeval *tv)
{
}

server MULTITHREADED TCPIP:

=============
| server.c : |
=============

int sendToPeer(ClnHdr *c,BYTE *payload,UINT32 msgsize,int msgtype,int mark)
    ...
    case TCP6:
    case TCP:
      if (c->ep.sck == 0) ccerr(gClientIsClosing ? 0 : tcp_connect_error);
#     if defined(MULTITHREADED)
      if (gRunTransportInSeparateThread && msgtype == SRV_RSP_) //gRunTransportInSeparateThread = TRUE by default + server response to client
      {
        if ((bckt=findBucket(c->ep.sck,FALSE)) != NULL) sem = bckt->sndSem;  // bucket semaphore (for this client)
        if ((cc=putStreamParams(c,payload,msgsize,mark)) != 0) break;
        ReleaseSystemSemaphore(sem);                            // release the semaphore -> the bucket thread wakes up and sends the data
        cc = 0;
        break;
      }
#     endif
      /* else fall thru ... */
    case PIPE:
    case UDP6:
    case UDP:
	...

Single threaded just falls through and sends data out as per UDP clients => on this thread

=============
| syslib.c: |
=============

HREAD_TYPE sckSendThreadTask(THREAD_PARAM lpvThreadParam)
{
  ...
  while (!ServerExitCondition && bckt->sdThrState == SD_THREAD_RUNNING)
  {
    WaitForSemaphore(hSem,-1);
    if (bckt->sdThrState == SD_THREAD_STOPPING) ccerr(0);
    while (bckt->sdTbl[bckt->sdTblTail].isready)
    { /* something needs to be sent out */
      ...
      if ((cc=sendIpData(&sdt->dst,sdt->payload,sdt->msgsize,SRV_RSP_,type,FALSE,FALSE)) != 0)
      { /* wasn't delivered */
        ...
      }
      ...
    }
  }
  ...
  return 0;
}

client MULTITHREADED TCPIP :
=============
| syslib.c: |
=============

THREAD_TYPE sckRecvThreadTask(THREAD_PARAM lpvThreadParam) => thread for every target server 

  while (bckt->sdThrState == SD_THREAD_RUNNING)
  { /* block on recv until a socket error happens */
    if (bckt == NULL) goto recvErr; /* can happen if reassigned */
    if (bckt->sdThrState == SD_THREAD_STOPPING) break;
    fds[0].fd = sck; fds[0].events = POLLIN; fds[0].revents = 0;
    if ((nready=poll(fds, 1, 1000)) < 0 || pollerr(0))
    {
      if (errno == EINTR) continue;
      rprtSckErr("sckRecvThreadTask", "poll", sck, -1, 0, NULL);
      goto recvErr;
    }
    if (nready == 0) continue;
    if ((nread=recv(sck,(char *)bckt->clrbuf,bckt->clrlen,0)) > 0)
    {
	  ...
      processTCPDataPacket(sck,bckt->clrbuf,nread,sckadr,TCP);
	  ...
    }
	...
  }
  
Single threaded: TCP/IP handled along with UDP etc. in 

=============
| client.c: |
=============

void doIPConsumer(void)  
{
    ...
#   ifndef MULTITHREADED
    /* the next few sockets have their own threads in a multi-threaded build */
    if (WaitForSystemMutex(hLinkLstMutex, gSystemTick) == 0)
    {
      TCPSCKT *sckt;
      p = (gAfInet == AF_INET6) ? TCP6 : TCP;
      for (sckt=tcpClnSckTbl; sckt != NULL; sckt = sckt->nxt)
        recvIpData(getFds(fds,nfds,sckt->sck),&sckt->sck,p);
      ReleaseSystemMutex(hLinkLstMutex);
    }
    if (gListenForMCasts) 
    { /* something on the multicast socket ? */
      p = (gAfInet == AF_INET6) ? UDP6 : UDP;
      if (mcastClnSck != 0) recvIpData(getFds(fds,nfds,mcastClnSck),&mcastClnSck,p);
    }
    if (glbClnSck > 0 && fds_isset(glbClnSck))
    { /* something on the globals socket ? */
      _socklen_t len = sizeof(sckadr);
      if ((nread=recvfrom(glbClnSck,(char *)clnWorkArea,GCAST_BUFFER_SIZE,0,(struct sockaddr *)&sckadr,&len)) > 0)
      {
        getGlobalUpdate(&sckadr,clnWorkArea);
      }
    }
#   else
    UNUSED(idx); /* avoid a warning */
#   endif /* MULTITHREADED */
    ...
