Click here to Skip to main content
13,198,068 members (67,154 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I am using UDP Server which receives data through port 50001. I used wireshark to monitor the data. Here the data what i receive in UDP server buffer and what data is showing in wireshark is not matching fully . but some places it is matching exactly ...What could be the reason for this? here is the receiver code for UDP server

char mesg[50];

n=recvfrom(sockfd,mesg,50,0,(struct sockaddr*)&cliaddr,&len);

the values whatever is coming from client should be in the range of 3000 to -3000 but in some places it is going to 30000 to -30000. In wireshark i plotted that values it is coming exactly in 3000 to -3000 range. but if i plot the received buffer it is giving in the range of 3000 to -3000 but also more values are in the range of 30000 to -30000
Posted 4-Apr-13 22:51pm
Updated 4-Apr-13 23:08pm
nv3 5-Apr-13 4:59am
Please show also the two results that you got from wireshark and your program. That would help making a good guess what the difference are and what they are coming from. (Use the "Improve question" button to append that information to your question.)

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Your fwrite call is wrong as it is assuming there are 50 characters in the received message. You should be using the value returned from the call to recvfrom thus:
n = recvfrom(sockfd, mesg, 50, 0, (struct sockaddr*)&cliaddr, &len);
fwrite(mesg, 1, n, fp);
20038427 5-Apr-13 5:46am
Thanks Mr.Richard MacCuthan ...still the problem exists ...if i plot the output of the receive buffer it should be 3KHz here i am getting 3KHz but also some value going upto 30MHz ...
Richard MacCutchan 5-Apr-13 5:52am
Well , I am afraid it is impossible to guess what else is happening. You need to check all your code to ensure that you are only processing the actual number of characters received on each message.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.171020.1 | Last Updated 5 Apr 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100