Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9008245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:53:50+00:00 2026-06-16T01:53:50+00:00

I have a working code running on a RedHat installed Linux with kernel 2.6.18-194.el5

  • 0

I have a working code running on a RedHat installed Linux with kernel 2.6.18-194.el5 #1 SMP x86_64.

When I moved the code to a newly installed machine with CentOS 6.3 the same code failed with

Error assigning socket option: Numerical argument out of domain

The kernel version of the latter machine is 2.6.32-279.el6.x86_64 #1 SMP

Below is the code of what’s both working and failing in the machines, respectively.

    struct timeval          tv;

    tv.tv_sec       = 0;
    tv.tv_usec      = 1500000;

    if (setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(struct timeval)) != 0)
    {
            LM_ERR("Error assigning socket option: %s", strerror( errno ));
            return FALSE;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T01:53:51+00:00Added an answer on June 16, 2026 at 1:53 am

    Try using

    tv.tv_sec       = 1;
    tv.tv_usec      = 500000;
    

    I’ve seen some implementations not accepting tv_usec above 10^6.

    Edit: The issue is interesting enough to dig a little bit. Looking for SO_RCVTIMEO in the kernel source code I’ve found the following piece of code in net/core/sock.c:

    int sock_setsockopt(struct socket *sock, int level, int optname,
                char __user *optval, unsigned int optlen)
    {
    
       / ... /    
       switch (optname) {
    
       / ... /    
    
       case SO_RCVTIMEO:
            ret = sock_set_timeout(&sk->sk_rcvtimeo, optval, optlen);
            break;
    
       / ... /    
    }
    

    The beginning of the sock_set_timeout() function indeed contains some range checking:

    static int sock_set_timeout(long *timeo_p, char __user *optval, int optlen)
    {
        struct timeval tv;
    
        if (optlen < sizeof(tv))
            return -EINVAL;
        if (copy_from_user(&tv, optval, sizeof(tv)))
            return -EFAULT;
        if (tv.tv_usec < 0 || tv.tv_usec >= USEC_PER_SEC)
            return -EDOM;
    
        /* ... */
    }
    

    Now we know enough to do some git blame-ing 🙂 The change was introduced with the following changeset:

    commit ba78073e6f70cd9c64a478a9bd901d7c8736cfbc 
    Author: Vasily Averin <vvs@sw.ru> 
    Date:   Thu May 24 16:58:54 2007 -0700
    
    [NET]: "wrong timeout value" in sk_wait_data() v2
    
    sys_setsockopt() do not check properly timeout values for 
    SO_RCVTIMEO/SO_SNDTIMEO, for example it's possible to set negative timeout
    values. POSIX do not defines behaviour for sys_setsockopt in case negative
    timeouts, but requires that setsockopt() shall fail with -EDOM if the send and
    receive timeout values are too big to fit into the timeout fields in the socket
    structure. 
    In current implementation negative timeout can lead to error messages like
    "schedule_timeout: wrong timeout value".
    
    Proposed patch:
    - checks tv_usec and returns -EDOM if it is wrong
    - do not allows to set negative timeout values (sets 0 instead) and outputs
      ratelimited information message about such attempts.
    
    Signed-off-By: Vasily Averin <vvs@sw.ru>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    

    I believe that the commit comment explains everything. As far as I can see this change was included in 2.6.22-rc3.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have working code of js, it shows different div for selected option. <html>
I have some working code with a crutch to add BOM marker to a
I have this working code, but now i need to be able to change
I have this (working) CPU code: #define NF 3 int ND; typedef double (*POT)(double
I have a working JavaScript code below which dynamically creates JSON object using JSON.parse
As a beginner in Ocaml, I have this current working code: ... let ch_in
I have this code working in C#: var request = (HttpWebRequest)WebRequest.Create(https://x.com/service); request.Method = GET;
I have been working on some code to submit an uploaded image to PHP
In YUI I have following code working for mouse wheel. How do I make
Hi I have been working on this code that creates a table with radio

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.