TCPClientSocket::TCPClientSocket(IPAddress &cServAddr, int iServPort) : TCPSocket((cServAddr.GetAddressFamily() == AF_INET6)) { Connect(cServAddr, iServPort); SetLocal(); SetConnected(); }
TCPServerSocket::TCPServerSocket(IPAddress &cLocalAddr, int iPortNo, int iBackLog) : TCPSocket((cLocalAddr.GetAddressFamily() == AF_INET6)) { const int iReUseAddrFlag = 1; SetSockOpt(SOL_SOCKET, SO_REUSEADDR, &iReUseAddrFlag, sizeof(iReUseAddrFlag)); Bind(cLocalAddr, iPortNo); SetLocal(); Listen(iBackLog); }
void SocketAddress::SetIPAddress(IPAddress &cAddr) { psaGeneric->sa_family = cAddr.GetAddressFamily(); if (psaGeneric->sa_family == AF_INET6) { bcopy(cAddr.Get_in_addr(), &(psaIP6Addr->sin6_addr), cAddr.Get_in_addr_length()); } else { bcopy(cAddr.Get_in_addr(), &(psaIP4Addr->sin_addr), cAddr.Get_in_addr_length()); } }
SocketBase::SocketBase(int iNewSockDesc) : mutexSocket() { IPAddress cLocalAddr; int iLocalPort; if (bFirstInstance) { signal(SIGIO, &IOSignalHandler); bFirstInstance = false; } if (iNewSockDesc < 0) throw SocketException(SocketException::errBadDescriptor); iSockDesc = iNewSockDesc; GetSockName(cLocalAddr, iLocalPort); bIPv6Socket = (cLocalAddr.GetAddressFamily() == AF_INET6); }