LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 09-26-2005, 09:50 AM   #1
stephenwalter
Member
 
Registered: Jul 2005
Location: india,coimbatore
Distribution: Fedora core 4
Posts: 85

Rep: Reputation: 15
problems receving data in socket programming


Hello all,
Iam working on an application which sends a character buffer to a server using the sendto() call . Sending of the data is sucessfull . But when i try to receive the response from the server in the same port to which the socket is binded iam not able to read the response. But iam sure that the server has generated a response.But the RECVFROM() call returns the number of bytes read as 920 . but when i try to dump the buffer into a text file some unknown format content is getting stored. Is there anyway to solve this issue cos everything looks to be alright ie no error messages nothing. Any solutions to this problem wud be very helpful.


Regards
S.Suresh stephen
 
Old 09-26-2005, 10:16 AM   #2
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
Sounds like maybe the protocol you use sends and receives binary data, but you are trying to dump it as plain text... Maybe if we knew more about the protocol you are using. Did you design the protocol yourself? Is it a standard protocol? Is it a protocol specific to the server you are sending to? Where did you get the information for how to create the packet to send? The information for what you get in response should be found in the same document(s).
 
Old 09-26-2005, 04:40 PM   #3
cyent
Member
 
Registered: Aug 2001
Location: ChristChurch New Zealand
Distribution: Ubuntu
Posts: 346

Rep: Reputation: 76
Hints...

Double check that something else isn't sending to that port. Maybe get client and server to use another port.

Use strace.

The strace is an absolute life saver in these cases.

Use valgrind

_always_ check and report every return code from every system call.
 
Old 09-27-2005, 02:04 AM   #4
stephenwalter
Member
 
Registered: Jul 2005
Location: india,coimbatore
Distribution: Fedora core 4
Posts: 85

Original Poster
Rep: Reputation: 15
Hello deiussum,
Thanks for ur reply . The request that iam trying to send is a SIP request and so is the response but it is transmitted over tcp as udp datagrams (request is of the type char ) and the request is transmitted sucessfull across to the server and the server also generates the expected response. So there is no issue in the SIP protocol. It is just receving the response in the socket is causing problems.
 
Old 09-27-2005, 10:29 AM   #5
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
I'm confused. You say the server generates the expected response, but yet you also say you have problems receiving the response. If you have trouble receiving the response, how do you know it is the expected response?

Did you code both the client and the server? Maybe showing us a bit of the offending code would help. (In [ code] tags of course. )

I'm not familiar with the SIP protocol, but looked at RFC 2543 briefly. It appears it is a text based protocol, so my theory of you trying to display binary data as text doesn't hold up. Maybe also show an example of this "unknown format content." Maybe you are not NULL terminating the data you receive?

I'm also not quite sure what you mean by "transmitting over tcp as udp datagrams." Are you somehow simulating UDP packets, but using the TCP protocol? If you are truly using TCP, you should probably be using recv instead of recvfrom.
 
Old 09-29-2005, 11:58 PM   #6
stephenwalter
Member
 
Registered: Jul 2005
Location: india,coimbatore
Distribution: Fedora core 4
Posts: 85

Original Poster
Rep: Reputation: 15
hi ,
I have fixed the issue the issue is not with the network. It was just with a header field that i shud not have added in my request. It was a problem with the server cos i added that header to the request. Anyway thank u very much for ur help.

Regards,
S.SureshStephen
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Socket programming problems marri Programming 5 10-06-2005 04:11 PM
socket programming iiit Programming 2 07-05-2005 04:02 PM
socket programming pantera Programming 7 09-30-2004 03:39 PM
want help in socket programming valib4u *BSD 2 09-11-2003 11:17 PM

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

All times are GMT -5. The time now is 11:04 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration