Click here to Skip to main content
15,918,889 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralBinding socket not working in win98 Pin
dasnov21-Jun-05 19:22
dasnov21-Jun-05 19:22 
GeneralWindows Services Pin
21-Jun-05 18:39
suss21-Jun-05 18:39 
GeneralRe: Windows Services Pin
ThatsAlok21-Jun-05 18:51
ThatsAlok21-Jun-05 18:51 
Generalclient-server Pin
ask_you21-Jun-05 18:33
ask_you21-Jun-05 18:33 
GeneralRe: client-server Pin
munawar196821-Jun-05 19:10
munawar196821-Jun-05 19:10 
GeneralRe: client-server Pin
ask_you21-Jun-05 19:19
ask_you21-Jun-05 19:19 
GeneralRe: client-server Pin
munawar196821-Jun-05 19:28
munawar196821-Jun-05 19:28 
GeneralRe: client-server Pin
pierrekande21-Jun-05 22:17
pierrekande21-Jun-05 22:17 
I suppose that you have a good level on networking programming
then do this if not just forget about, sorry

Normaly with Socket API it is not possible, because while calling accept() the client get connect.
For that you need to use some firewall in your program for packet filter
here is am easy way to do that:

INTERFACE_HANDLE hInterface; // interface
PFFORWARD_ACTION defaultAction=PF_ACTION_DROP;
// create the interface
// I create the interface. Predefined acctions, forward all.
DWORD errorCode = PfCreateInterface(0,defaultAction,defaultAction,FALSE,TRUE,&hInterface);
if(errorCode != NO_ERROR)
{
return -1;
}


// Bind the Ip Address with the interface
PBYTE lIp = (PBYTE)&ip; //the ip address of your card
errorCode = PfBindInterfaceToIPAddress(hInterface, PF_IPV4, lIp);

if(errorCode != NO_ERROR)
{
PfDeleteInterface(hInterface);
hInterface = NULL;
return -1;
}
/////////////////////////////////////////////////////
now here do with the code
{
DWORD result;
PIP_ADAPTER_INFO pAdapterInfo = NULL, aux;
IP_ADDR_STRING *localIp;
unsigned long len = 0;
GetAdaptersInfo(pAdapterInfo, &len);

pAdapterInfo = (PIP_ADAPTER_INFO) malloc (len);

result = GetAdaptersInfo(pAdapterInfo, &len);

if(result != ERROR_SUCCESS)
{
AfxMessageBox("Error getting adapters info.");
return;
}
// Fill the real filter struct
PF_FILTER_DESCRIPTOR ipFlt;
ipFlt.dwFilterFlags = FD_FLAGS_NOSYN;
ipFlt.dwRule = 0;
ipFlt.pfatType = PF_IPV4;
ipFlt.dwProtocol = protocol; // value is : TCP =6;UDP=17 or ICMP=1
ipFlt.fLateBound = 0;
ipFlt.wSrcPort = srcPort; // source port
ipFlt.wSrcPortHighRange = srcPort; // source port range
ipFlt.wDstPort = dstPort; // destination port
ipFlt.wDstPortHighRange = dstPort; // destination port range

unsigned long lIpSrc = CharToIp(srcIp); //chartoIP convert (*.*.*.*) to long
unsigned long lIpDst = CharToIp(dstIp);
unsigned long lMaskSrc = CharToIp(srcMask);
unsigned long lMaskDst = CharToIp(dstMask);

ipFlt.SrcAddr = (PBYTE) &lIpSrc;
ipFlt.SrcMask = (PBYTE) &lMaskSrc;
ipFlt.DstAddr = (PBYTE) &lIpDst;
ipFlt.DstMask = (PBYTE) &lMaskDst;
DWORD errorCode;

// I add the filter
if(direction == IN_DIRECTION || direction == ANY_DIRECTION)
errorCode = PfAddFiltersToInterface(hInterface,1,&ipFlt,0,NULL,NULL);

if(direction == OUT_DIRECTION || direction == ANY_DIRECTION)
errorCode = PfAddFiltersToInterface(hInterface,0,NULL,1,&ipFlt,NULL);
}

Not that when stopping your server
call PfDeleteInterface(hInterface); to delete your interface
Pierre kande
For serving you
GeneralI want to get E-Mail account infomation of OutLook( express , XP, 2003... ) Pin
Blue-Bird21-Jun-05 16:50
Blue-Bird21-Jun-05 16:50 
GeneralRe: I want to get E-Mail account infomation of OutLook( express , XP, 2003... ) Pin
David Crow21-Jun-05 17:34
David Crow21-Jun-05 17:34 
GeneralRe: I want to get E-Mail account infomation of OutLook( express , XP, 2003... ) Pin
Christian Graus21-Jun-05 18:08
protectorChristian Graus21-Jun-05 18:08 
GeneralRe: I want to get E-Mail account infomation of OutLook( express , XP, 2003... ) Pin
ThatsAlok21-Jun-05 19:46
ThatsAlok21-Jun-05 19:46 
GeneralRe: I want to get E-Mail account infomation of OutLook( express , XP, 2003... ) Pin
David Crow22-Jun-05 3:03
David Crow22-Jun-05 3:03 
GeneralRe: I want to get E-Mail account infomation of OutLook( express , XP, 2003... ) Pin
Blue-Bird21-Jun-05 19:22
Blue-Bird21-Jun-05 19:22 
GeneralRe: I want to get E-Mail account infomation of OutLook( express , XP, 2003... ) Pin
David Crow22-Jun-05 3:07
David Crow22-Jun-05 3:07 
GeneralRe: I want to get E-Mail account infomation of OutLook( express , XP, 2003... ) Pin
Blue-Bird22-Jun-05 6:46
Blue-Bird22-Jun-05 6:46 
GeneralRe: I want to get E-Mail account infomation of OutLook( express , XP, 2003... ) Pin
munawar196821-Jun-05 19:13
munawar196821-Jun-05 19:13 
GeneralRe: I want to get E-Mail account infomation of OutLook( express , XP, 2003... ) Pin
Blue-Bird21-Jun-05 19:20
Blue-Bird21-Jun-05 19:20 
GeneralRe: I want to get E-Mail account infomation of OutLook( express , XP, 2003... ) Pin
munawar196821-Jun-05 19:35
munawar196821-Jun-05 19:35 
GeneralRe: I want to get E-Mail account infomation of OutLook( express , XP, 2003... ) Pin
Blue-Bird21-Jun-05 19:39
Blue-Bird21-Jun-05 19:39 
GeneralRe: I want to get E-Mail account infomation of OutLook( express , XP, 2003... ) Pin
munawar196821-Jun-05 19:45
munawar196821-Jun-05 19:45 
GeneralRe: I want to get E-Mail account infomation of OutLook( express , XP, 2003... ) Pin
Blue-Bird21-Jun-05 19:49
Blue-Bird21-Jun-05 19:49 
GeneralRe: I want to get E-Mail account infomation of OutLook( express , XP, 2003... ) Pin
Blue-Bird21-Jun-05 19:54
Blue-Bird21-Jun-05 19:54 
GeneralRe: I want to get E-Mail account infomation of OutLook( express , XP, 2003... ) Pin
munawar196821-Jun-05 20:07
munawar196821-Jun-05 20:07 
GeneralRe: I want to get E-Mail account infomation of OutLook( express , XP, 2003... ) Pin
Blue-Bird21-Jun-05 20:32
Blue-Bird21-Jun-05 20:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.