![]() |
Bind() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
| Public Function |
Declared in: SpoofSocket.h |
Declaration
virtual BOOL Bind(
LPCSTR lpSourceAddress,
int iPort=0);
DescriptionBind to a specific address
Function Body
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)
See Also
This web site was generated
using Surveyor V4.50.811.1. Click
here
for more information. |
Site content copyright © 2001 Barak Weichselbaum. See the About page for additional notices. This page last updated: 27 Jun 2001. |