Click here to Skip to main content
15,895,142 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionStack corruption - STRANGE PROBLEM!! Pin
Shailesh H22-Dec-09 3:44
Shailesh H22-Dec-09 3:44 
AnswerRe: Stack corruption - STRANGE PROBLEM!! Pin
Shailesh H22-Dec-09 4:07
Shailesh H22-Dec-09 4:07 
GeneralRe: Stack corruption - STRANGE PROBLEM!! [modified] Pin
Code-o-mat22-Dec-09 4:30
Code-o-mat22-Dec-09 4:30 
AnswerRe: Stack corruption - STRANGE PROBLEM!! Pin
Rajesh R Subramanian22-Dec-09 4:42
professionalRajesh R Subramanian22-Dec-09 4:42 
AnswerRe: Stack corruption - STRANGE PROBLEM!! Pin
Maximilien22-Dec-09 4:11
Maximilien22-Dec-09 4:11 
QuestionRe: Stack corruption - STRANGE PROBLEM!! Pin
Nelek22-Dec-09 4:17
protectorNelek22-Dec-09 4:17 
QuestionRe: Stack corruption - STRANGE PROBLEM!! Pin
22491722-Dec-09 13:31
22491722-Dec-09 13:31 
QuestionNot able to sniff TCP packet on windows Vista. But could do so on XP Pin
Aseem Sharma22-Dec-09 1:08
Aseem Sharma22-Dec-09 1:08 
Hi friends,

I am having just one month of experience in network programming. I want to sniff TCP packets using Winsock. I could right the code for that as below. It worked on XP 32 bit but not on Vista Home 32 bit machine.

SOCKET	sniffSocket;
if((sniffSocket= socket(AF_INET, SOCK_RAW, IPPROTO_IP))==SOCKET_ERROR)
{	
  return 0;
}
struct sockaddr_in src;
memset(&src, 0, sizeof(src));
src.sin_addr.S_un.S_addr = inet_addr (pAdapterInfo->IpAddressList.IpAddress.String);
// pAdapterInfo is the adapter as selected by the user
src.sin_family = AF_INET;
src.sin_port = 0;

if (bind(sniffSocket,(struct sockaddr *)&src, sizeof(src)) == SOCKET_ERROR)
{	
  return 0;
}

int j=1;
if (WSAIoctl(sniffSocket, SIO_RCVALL, &j, sizeof(j), 0, 0, &in, 0, 0) == SOCKET_ERROR)
{	
  return 0;
}

char *pkt_data = (char *)malloc(65536); //Its Big!
int res;
do
{
  res = recvfrom(sniffSocket, pkt_data, 65536, 0, 0, 0); //Eat as much as u can
  ...
  ...
}
while (res > 0);
...
...


The above code is working fine on XP. I could sniff TCP/IP packets (in pkt_data variable) this way. But when I run the same code on Vista, I am able to trace only UDP/IP packets. Can anybody tell me please why is it not working on Vista? I mean what is the problem with my code that I cannot sniff TCP/IP packets?

My second query: A system can have multiple adapters/devices. When we type a web-site address on a browser, we don't tell which adapter to connect to. Browser automatically opens adapter that is connected to internet. How it does that? I mean how can I detect which adapter is being used for internet connection? Is there any Winsock API for the that?

Thanks in Advance
Regards
Aseem

modified on Wednesday, December 23, 2009 1:30 AM

QuestionRe: Not able to sniff TCP packet on windows Vista. But could do so on XP Pin
CPallini22-Dec-09 1:34
mveCPallini22-Dec-09 1:34 
AnswerRe: Not able to sniff TCP packet on windows Vista. But could do so on XP Pin
Aseem Sharma22-Dec-09 20:16
Aseem Sharma22-Dec-09 20:16 
QuestionUnable to start the windows service in Windows server 2003 Pin
Arun Abraham Jose22-Dec-09 0:13
Arun Abraham Jose22-Dec-09 0:13 
AnswerRe: Unable to start the windows service in Windows server 2003 Pin
Richard Andrew x6422-Dec-09 10:22
professionalRichard Andrew x6422-Dec-09 10:22 
QuestionAccess violation iin SendMessage Pin
Anu_Bala21-Dec-09 23:49
Anu_Bala21-Dec-09 23:49 
AnswerRe: Access violation iin SendMessage Pin
CPallini22-Dec-09 0:11
mveCPallini22-Dec-09 0:11 
AnswerRe: Access violation iin SendMessage Pin
KingsGambit22-Dec-09 0:17
KingsGambit22-Dec-09 0:17 
AnswerRe: Access violation iin SendMessage Pin
Maximilien22-Dec-09 0:22
Maximilien22-Dec-09 0:22 
GeneralRe: Access violation iin SendMessage Pin
Anu_Bala22-Dec-09 0:48
Anu_Bala22-Dec-09 0:48 
GeneralRe: Access violation iin SendMessage Pin
CPallini22-Dec-09 1:35
mveCPallini22-Dec-09 1:35 
Questionsh_read: Undeclared identifier Pin
Anu_Bala21-Dec-09 22:37
Anu_Bala21-Dec-09 22:37 
AnswerRe: sh_read: Undeclared identifier Pin
KingsGambit21-Dec-09 23:06
KingsGambit21-Dec-09 23:06 
GeneralRe: sh_read: Undeclared identifier Pin
Anu_Bala21-Dec-09 23:12
Anu_Bala21-Dec-09 23:12 
Questionerror C2487 Pin
Nandu_77b21-Dec-09 22:33
Nandu_77b21-Dec-09 22:33 
AnswerRe: error C2487 Pin
KingsGambit21-Dec-09 23:10
KingsGambit21-Dec-09 23:10 
QuestionRe-Mssql question Pin
MsmVc21-Dec-09 20:28
MsmVc21-Dec-09 20:28 
AnswerRe: Re-Mssql question Pin
Code-o-mat21-Dec-09 21:00
Code-o-mat21-Dec-09 21:00 

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.