LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 01-03-2005, 01:03 AM   #1
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Rep: Reputation: 50
Can't recv()


I have a really big program here and at the first recv() on a socket I get error. The recv() return -1 and I can't understand why. It has been working before (I reinstalled slackware).

The program is too complex to show or explain. I just wondered if someone knows some possible wrongs when recv() returnes -1.

I can send() data to the socket and it works fine. But whenever I try to recv() it fails and returns -1.
 
Old 01-03-2005, 01:16 AM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
Check what the OS has set errno to (see man errno) and check it against errors possibly raised by the recv system call (from the man page there are several -- man recv will enumerate them for you).
 
Old 01-04-2005, 02:49 PM   #3
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Original Poster
Rep: Reputation: 50
Ok. So I checked and I get errno set to 14, which means EFAULT (Bad address).

Now what should I do with this information. The code worked before I reinstalled slackware, what can the problem be? And which address is bad, the servers or the clients? Notice that I can send() as much as I want, the problem is to recv().
 
  


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
send/recv binary files with C++ sockets dafatdude Programming 3 02-12-2006 08:02 AM
recv() function of SOCKET ashucool83 Programming 1 10-08-2005 07:38 PM
function recv() in socket husniteja Programming 1 08-18-2004 09:06 AM
How do I add a timeout for the recv() cmd? dravya Programming 6 07-14-2004 09:28 AM
recv() buffer linuxanswer Programming 1 03-22-2004 12:11 PM

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

All times are GMT -5. The time now is 04:56 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