Set the local port to the specified port and the local address to any interface.
Definition at line 133 of file PracticalSocket.cpp. 00133 { 00134 // Bind the socket to its port 00135 sockaddr_in localAddr; 00136 memset(&localAddr, 0, sizeof(localAddr)); 00137 localAddr.sin_family = AF_INET; 00138 localAddr.sin_addr.s_addr = htonl(INADDR_ANY); 00139 localAddr.sin_port = htons(localPort); 00140 00141 if (bind(sockDesc, (sockaddr *) &localAddr, sizeof(sockaddr_in)) < 0) { 00142 throw SocketException("Set of local port failed (bind())", true); 00143 } 00144 }
|