![]() |
Create() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
| Public Function |
Declared in: SpoofSocket.h |
Declaration
BOOL Create(
int iProtocol);
DescriptionCreate a socket
Function Body
//Close the socket if open
if (ValidSocket())
Close();
try
{
//Here we create the raw socket
if (m_Raw || iProtocol==IPPROTO_ICMP)
m_SpoofSocket=socket(AF_INET,SOCK_RAW,iProtocol);//iProtocol);
else
if (iProtocol==IPPROTO_TCP)
m_SpoofSocket=socket(AF_INET,SOCK_STREAM,iProtocol);
else if (iProtocol==IPPROTO_UDP)
m_SpoofSocket=socket(AF_INET,SOCK_DGRAM,iProtocol);
//Check for socket validity
if (m_SpoofSocket==INVALID_SOCKET)
{
//Error
SetLastError("Create");
return FALSE;
}
if (m_Raw)
{
//Set that the application will send the IP header
unsigned int iTrue=1;
if(setsockopt(m_SpoofSocket,IPPROTO_IP,IP_HDRINCL,(char*)&iTrue,sizeof(iTrue))==SOCKET_ERROR)
{
//Check for options error
SetLastError("Create");
return FALSE;
}
}
return TRUE;
}
ERROR_HANDLER_RETURN("Create",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. |