![]() |
Bind() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Public Function |
Declared in: SpoofSocket.h |
virtual BOOL Bind( LPCSTR lpSourceAddress, int iPort=0);
Bind to a specific address
try { //Quit if not ok if (!CheckSocketValid()) return FALSE; //Create the local address sockaddr_in soSrc; //Set to 0 memset(&soSrc,0,sizeof(soSrc)); soSrc.sin_family=AF_INET; if (lpSourceAddress) soSrc.sin_addr.s_addr=inet_addr(lpSourceAddress); else soSrc.sin_addr.s_addr=ADDR_ANY ; soSrc.sin_port=htons(iPort); //Now we need to bind it if (bind(GetHandle(),(sockaddr*)&soSrc,sizeof(soSrc))) { //Error SetLastError("Bind"); return FALSE; } else //Save the address m_ConnectedTo=soSrc; //If already has a source address then don't change it if (!m_SourceAddress) m_SourceAddress=lpSourceAddress; return TRUE; } ERROR_HANDLER_RETURN("Bind",FALSE)
![]() |
Site content copyright © 2001 Barak Weichselbaum. See the About page for additional notices. This page last updated: 24 Apr 2001. |