LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 07-28-2006, 10:28 AM   #1
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

Rep: Reputation: 50
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, 10:35 AM   #2
Ephracis
Senior Member
 
Registered: Sep 2004
Location: Sweden
Distribution: Ubuntu, Debian
Posts: 1,109

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

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 03:20 AM.
 
  


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

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

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