LinuxQuestions.org
Visit Jeremy's Blog.
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 07-28-2006, 11:28 AM   #1
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Rep: Reputation: 49
setsockopt: SO_RCVTIMEO


Hi,

I am trying to set receive timeout on my raw socket but it keeps telling me "invalid argument". Is there something I'm missing here?
Code:
int val = 0;
if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &val, sizeof(val))) {
       perror("setsockopt: rcvtimeo");
       exit(1);
}
 
Old 07-28-2006, 11:35 AM   #2
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Original Poster
Rep: Reputation: 49
Nevermind. It seems it takes a timeval as argument.
 
Old 03-18-2013, 03:43 AM   #3
niteen
Member
 
Registered: Mar 2013
Location: India
Distribution: Fedora
Posts: 61

Rep: Reputation: Disabled
Code:
        int val = 0;  
        struct timeval tv;
        tv.tv_sec = 30;  /* 30 Secs Timeout */
if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, (struct timeval *)&tv,sizeof(struct timeval)) {
       perror("setsockopt: rcvtimeo");
       exit(1);
}

Last edited by niteen; 03-18-2013 at 04:20 AM.
 
  


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
setsockopt() in kernel? hegdeshashi Linux - Networking 0 01-12-2006 01:17 AM
setsockopt Mercurius Programming 6 12-24-2005 08:16 AM
setsockopt with level IPPROTO_UDP longp Linux - Networking 0 07-12-2005 11:10 AM
Socket Programming: setsockopt: Protocol not available bonhomme Programming 5 06-30-2004 12:52 PM
Is SO_RCVTIMEO not supported on Linux ? SmitaJain Linux - Networking 0 01-30-2002 04:19 AM

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

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