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 5970021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:18:53+00:00 2026-05-22T20:18:53+00:00

I am developing a RTSP Source filter in C++, and I am using WINSOCK

  • 0

I am developing a RTSP Source filter in C++, and I am using WINSOCK 2.0 – blocking socket.

When I create a blocking socket, I set its SO_RCVTIMEO to 3 secs like so:

int ReceiveTimeout = 3000; 
int e = setsockopt(Socket, SOL_SOCKET, SO_RCVTIMEO, (char*)&ReceiveTimeout, sizeof(int));

My filter tries to connect to IP_ADDRESS:554 (554 is RTSP server port). If there is a server listening on that IP on the port 554, all goes well, but:

  1. If my filter creates a socket to an existing IP address, but on a random port which no one listens on, connect() waits for 3 secs and returns WSAETIMEDOUT. So after 3 secs, I know that the provided URL is bad.

  2. If my filter creates a socket to a non existing IP address, and tries to connect it, it hangs for about 10 secs before returning SOCKET_ERROR. So, SO_RCVTIMEO gets ignored if the IP doesn’t exist on the network…

QUESTION:
How can I set the timeout for a non existing IP, in the second case? Do I need to send ICMP PING first to see does the IP exist, or perform some other check like that?

Any help will be appreciated.
Thanx. 🙂

THE ANSWER TO MY PROBLEM

Because I am using blocking sockets, call to connect() blocks, until the connection is made, or the connection fails because the host is not responding, or it is refusing connection. If I set socket’s timeout to be 3 seconds, and try to connect to a host that doesn’t exist, my pc (client) will send TCP packet with SYN flag set, to initiate the Threeway handshake. Normally, the host, if up, will respond with TCP packet containing ACK and SYN flags set, and then, client (me) would send the TCP packet with ACK flag set. Then the connection is made. BUT if the host is down, and the SYN is sent, client waits until the 3 second timeout expires, and then tries AGAIN, and AGAIN, until the TcpMaxConnectRetransmissions (MICROSOFT ARTICLE) registry setting is reached, because the host can be UP but the SYN packet might get lost… My Windows XP has this setting at 4, I guess, so each time it tries to send SYN, it waits 3 seconds, and when the fourth try fails, it returns SOCKET_ERROR (after 12 secs), and sets WSAETIMEDOUT as the last WSA error.

The way around this is using non blocking sockets, and trying to manually measure the connection attempt time (because now the connect() wouldn’t block) as Martin James suggested.

Another way is to fiddle with the registry, which is the last resort…

  • 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-05-22T20:18:53+00:00Added an answer on May 22, 2026 at 8:18 pm

    Bite the bullet. The remote IP may not be running a PING server or PING may be blocked by some router, so it’s no help. Can you not just wait the 10 sec and then make whatever error indication you use?

    If you absolutely have to time out the attempted connection after 3 seconds, you can time it out yourself.

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

Sidebar

Related Questions

Developing Java, you have always learned that its best to create an ArrayList by
When developing whether its Web or Desktop at which point should a developer switch
developing iphone app, I have used a UIImageview and i have set an image
Developing iphone application using makkit framework. I have got the map view integrated in
Developing a simple game for the iPhone, what gives a better performance? Using a
Developing a chrome extension using javascript is one of my university projects. I don't
Developing using MVC-3, Razor, C# Been searching around and cannot find advice I'm looking
Developing an application using SWT to work in both Linux and Windows. I created
developing for Android phone(ver 1.5) I would like to know if there is an
im developing windows application using c#. i want to close the application and show

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.