LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-18-2005, 03:49 AM   #1
stephenwalter
Member
 
Registered: Jul 2005
Location: india,coimbatore
Distribution: Fedora core 4
Posts: 85

Rep: Reputation: 15
Unable to receive data in an udp socket


Hello all,
I am right now working on an application which makes use of 3 sockets and all these 3 sockets are udp sockets. Initially when i start executing the application one socket will be opened and a thread will begin to do a select on the socket to receive any messages from the server. Next when i issue a particular command the other two sockets would become active and those will also have a thread which does a select on both of them. Now comes the problem the messages which are sent to these two latter sockets are not being captured. To check the status of my ports i did a nmap and this is how it came out

PORT STATE SERVICE
111/udp open|filtered rpcbind
631/udp open|filtered unknown
701/udp open|filtered unknown
5353/udp open|filtered unknown
8000/udp open|filtered unknown ->opened when i execute a particular command
8001/udp open|filtered unknown ->opened when i execute a particular command
32768/udp open|filtered omad
36000/udp open|filtered unknown -> opened when i start execution

The open|filtered state means that nmap has not received any response from those ports.

The funniest part of the issue is this . When i do the nmap , at that particular instance alone the messages are received on those two sockets. I beleive that nmap must be sending NULL UDP packets to all the ports which we specify on a range to check the status. But otherwise iam not able to receive any messages in both the sockets. The issue is wierd and iam not able to find any solution for this issue. If anyone knows a way in which the issue cud be solved please let me know.

Regards,
S.Suresh Stephen
 
Old 11-18-2005, 05:32 PM   #2
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
Could you please post your socket code (the part of your code that relate to sockets)? Do you check if all functions return without errors?
 
Old 11-18-2005, 11:58 PM   #3
stephenwalter
Member
 
Registered: Jul 2005
Location: india,coimbatore
Distribution: Fedora core 4
Posts: 85

Original Poster
Rep: Reputation: 15
Hi Mara,
Thanks for ur reply. I was able to fix this issue with changing the firewall settings on my FC4 machine. I actually disabled my fire wall and then the messages on those two sockets were received by my application successfully. This still is confusing , then how come the udp messages on the first port alone are received properly. As far as my socket code is concern there are no issues cos for every single operation on the socket an error check is done and all three sockets are created with the same properties . The 3 sockets created are non blocking sockets.

Regards,

S.Suresh Stephen
 
Old 11-20-2005, 05:04 PM   #4
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
If you do nmap from the same machine, connections go via loopback interface, which is usually covered by a different set of iptables rules. That might be the cause.
 
Old 11-21-2005, 11:21 PM   #5
stephenwalter
Member
 
Registered: Jul 2005
Location: india,coimbatore
Distribution: Fedora core 4
Posts: 85

Original Poster
Rep: Reputation: 15
Hi Mara,
There is one more thing i need to ask u. If the fire wall is disabled is there a chance that the incoming udp packet may be corrupted. Cos as i said u previously. When i do the nmap i am able to receive the udp packets and there is no problems. When i disabled the fire wall and then the packet which came in actually crashed my application . I suspect a corruption in the udp packet. Is that a likely event???

Regards,

S.Suresh Stephen
 
Old 11-21-2005, 11:43 PM   #6
primo
Member
 
Registered: Jun 2005
Posts: 542

Rep: Reputation: 34
"Corruption" of the UDP packet is possible with nmap and a firewall lets you filter strange packets. I suspect there's a problem with the application. It'll be easier if you post the part of the code that's behaving that way.
 
Old 11-22-2005, 11:24 PM   #7
stephenwalter
Member
 
Registered: Jul 2005
Location: india,coimbatore
Distribution: Fedora core 4
Posts: 85

Original Poster
Rep: Reputation: 15
Hi,
Thanks for ur reply. The socket programming module of my application does work properly . The issue is that even when i try to write the message received into file opened in write binary mode , the fwrite shows that it has written the exact number of bytes that the recvfrom() call has returned. the problem is when i try to open the file using hexedit , there is no content in that file. But this is the same message which seems to cause a crash in my application . This message is basically an RTCP message sent as a udp packet . Even junk if any must be written into a file right???? . This iam not able to perform. I cannot post my code its against my organization rules.

Regards,

S.Suresh stephen
 
Old 11-24-2005, 05:11 AM   #8
primo
Member
 
Registered: Jun 2005
Posts: 542

Rep: Reputation: 34
Try to fflush( ) the stream everytime or use setbuf( ) and set it to NULL.
 
Old 11-24-2005, 11:20 PM   #9
stephenwalter
Member
 
Registered: Jul 2005
Location: india,coimbatore
Distribution: Fedora core 4
Posts: 85

Original Poster
Rep: Reputation: 15
Hi ,
I have found out the issue . The issue is not with the socket code. The socket code works perfectly. The issue is a memory corruption in a different layer. There is no problem with the udp packets which come in , no chance of corruption or anything. The memory corruption happens in a different place. Thanks very much for ur support and help in solving the issue.

Regards,

S.Suresh Stephen
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot read data at server socket, though client socket sends it jacques83 Linux - Networking 0 11-15-2005 01:58 PM
Unable to connect to UNIX socket /tmp/.esd/socket error while using grip dr_zayus69 Linux - Software 4 08-23-2005 07:28 PM
How to receive UDP and ICMP packets, by one UDP socket(PMTUD) myself_rajat Linux - Networking 0 05-28-2004 05:43 AM
UDP socket and ICMP messages myself_rajat Linux - Networking 0 05-25-2004 08:49 AM
Using Raw Socket for UDP myself_rajat Linux - Networking 0 05-17-2004 03:35 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration