/***************************************************************************** Function: SOCKET * TCPOpen(const LLADP * pLLAdp, const SOCKETPOOL * pSocketPool, void * pIPvXDest, uint16_t portRemote, uint16_t portLocal, IPSTATUS * pStatus) Summary: Opens a Socket for both Client and Server. If portRemote == 0 The socket is opened for listening. Description: Precondition: Parameters: pLLAdp - The adaptor to use hPMGR - A handle to the page manager to create the socket stream. pIPvXDest - The Dest IP to connect to if a client, ignored for a server open and may be NULL portRemote - The remote port to connect to if Client, MUST be 0 if this is a server open for listen portLocal - Local port to use, one will be assigned if zero pStatus - A pointer to a status variable to recieve the status of the open, This may be NULL Returns: The Socket if opened, NULL on failure ***************************************************************************/ HSOCKET TCPOpen(const LLADP * pLLAdp, HPMGR hPMGR, const void * pIPvXDest, uint16_t portRemote, uint16_t portLocal, IPSTATUS * pStatus) { TCPSOCKET * pSocket = IPSGetSocketFromSocketHeap(); return(TCPOpenWithSocket(pLLAdp, pSocket, hPMGR, pIPvXDest, portRemote, portLocal, pStatus)); }
void TCPServer::periodicTask(void) { FFLL * pffllServer = NULL; // look at all of the server objects while((pffllServer = (FFLL *) FFNext(&_ffptPeriodTask, pffllServer)) != NULL) { FFLL * pffllSocket = NULL; TCPServer& tcpServer = *((TCPServer *) (pffllServer->_this)); // for syntax sake if(ILIsIPSetup(tcpServer._pDEIPcK->_pLLAdp, NULL)) { while((pffllSocket = (FFLL *) FFNext(&tcpServer._ffptSockets, pffllSocket)) != NULL) { TCPSocket& tcpSocket = *((TCPSocket *) (pffllSocket->_this)); // for syntax sake // start listening on available sockets if(tcpSocket._classState == ipsNotInitialized && tcpSocket._socket.tcpState < tcpInvalid) { // get this listening if(TCPOpenWithSocket(tcpSocket._pDEIPcK->_pLLAdp, &tcpSocket._socket, tcpSocket._hPMGR, &IPListen, portListen, tcpServer._listeningPort, NULL) == &tcpSocket._socket) { if(tcpSocket._socket.tcpState == tcpListen) { tcpSocket._classState = ipsListening; } } } } } } }