LinuxQuestions.org
Review your favorite Linux distribution.
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 06-05-2005, 03:17 PM   #1
elluva
Member
 
Registered: Aug 2003
Location: Belguim, Ostend and Ghent
Distribution: Ubuntu
Posts: 600

Rep: Reputation: 30
C(sockets): 'Invalid argument' error when using MSG_OOB


When I try to receive Out-of-band data by using the MSG_OOB flag in rcv(), I always get an error saying 'Invalid argument'.
The weird thing is that I can get the data through a rcv() using 0 as flags, which can't be right since the data was sent with send() using the MSG_OOB flag.
 
Old 06-06-2005, 01:50 PM   #2
nukkel
Member
 
Registered: Mar 2003
Location: Belgium
Distribution: Hardened gentoo
Posts: 323

Rep: Reputation: 30
From man 2 getsockopts:

With protocols that support out-of-band data, the SO_OOBINLINE
option requests that out-of-band data be placed in the
normal data input queue as received; it will then be
accessible with recv or read calls without the MSG_OOB
flag. Some protocols always behave as if this option is
set.


So it's possible that on the receiving end SO_OOBINLINE is set, which means that even with send(..., MSG_OOB), the data will arrive in-band nonetheless. Maybe use an extra setsockopts() after calling socket(), just to be sure?

Just a tought
 
Old 06-08-2005, 05:17 AM   #3
elluva
Member
 
Registered: Aug 2003
Location: Belguim, Ostend and Ghent
Distribution: Ubuntu
Posts: 600

Original Poster
Rep: Reputation: 30
|->ok, thanks! Now what would be the option to use to negate this setting?
|
ok, forget about this, stupid questions 'man 2 setsockopt' told me:
... int setsockopt(int s, int level, int optname, const void *optval, socklen_t optlen);...
and Most socket-level options utilize an int parameter for optval. For setsockopt, the parameter should be non-zero to enable a boolean option, or zero if the option is to be disabled.

Thanks!

Last edited by elluva; 06-08-2005 at 06:31 AM.
 
Old 06-08-2005, 06:31 AM   #4
nukkel
Member
 
Registered: Mar 2003
Location: Belgium
Distribution: Hardened gentoo
Posts: 323

Rep: Reputation: 30
To make sure oob data will be received out-of-band, do something along the lines of
Code:
int false = 0;
retval = setsockopt(sock, SOL_SOCKET, SO_OOBINLINE, &false, sizeof (int));
if (retval) exit (1);
Don't forget to include sys/types.h and sys/socket.h .

Again, I'm not sure this is what causes your problem, but it certainly has the right "symptoms"... Anyway, it won't hurt to include this code.

If this doesn't help, I'd suggest capturing the traffic using e.g. the ethereal tool, to make sure if the data is indeed being sent as OOB.

Happy programming!
 
Old 06-08-2005, 06:34 AM   #5
nukkel
Member
 
Registered: Mar 2003
Location: Belgium
Distribution: Hardened gentoo
Posts: 323

Rep: Reputation: 30
OK, I saw your edit too late ...
 
Old 06-08-2005, 08:15 AM   #6
elluva
Member
 
Registered: Aug 2003
Location: Belguim, Ostend and Ghent
Distribution: Ubuntu
Posts: 600

Original Poster
Rep: Reputation: 30
no probs, ethereal is a great idea... how didn't I think of this before?!
 
Old 06-08-2005, 09:16 AM   #7
elluva
Member
 
Registered: Aug 2003
Location: Belguim, Ostend and Ghent
Distribution: Ubuntu
Posts: 600

Original Poster
Rep: Reputation: 30
ok, I set the option SO_OOBINLINE to false, but it still come through otherwise. I am using TCP, TCP should support this shouldn't it? Ethereal marks them as urgent, so it really should work if everything is set right at the receiver side...
 
  


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
Accept(): Invalid Argument bonhomme Programming 6 07-14-2012 10:12 PM
Getting a "KDSETKEYCODE: Invalid argument" error. sk545 Ubuntu 1 11-12-2005 05:42 AM
xawtv - invalid argument liguorir Linux - Software 0 06-17-2003 08:55 PM
installation Error mounting sda1: Invalid Argument sadirmata Linux - Software 4 01-31-2002 10:37 AM
installation error: Error mounting sda1: Invalid Argument sadirmata Linux - Newbie 1 01-29-2002 02:28 AM

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

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