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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:52:39+00:00 2026-05-29T03:52:39+00:00

The RTP specification says that the RTCP packets for a given RTP stream will

  • 0

The RTP specification says that the RTCP packets for a given RTP stream will be sent on a port that is +1 of the main RTP port. So for example, if you have video arriving on RTP port 9010, then on port 9011, you can expect RTCP packets.

When I’m negotiating a unicast stream (via the RTSP protocol), I have to suggest pair of ports that I would like the video sent to me on (1 for RTP, and 1 for RTCP)…

Now, I know that if I bind a socket with a port of 0, the system will pick a free port from the ephemeral range… The problem I have is that I actually need a pair of ports, and I need the RTCP port to be +1 of the RTP port (in fact, I think I need the RTP port to be an even number).

Is there a way to locate a pair of free ports? How is this normally done?

  • 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-29T03:52:39+00:00Added an answer on May 29, 2026 at 3:52 am

    You get a random one, then try the next one up.

    If the bind() call on the second port fails with EADDRINUSE, rinse and repeat…

    For what it’s worth, on most systems if the two calls are close enough you’ll likely not have to repeat the sequence.

    Ephemeral ports are usually assigned sequentially, so the only way the next port won’t be free will be if either the port was already being used by a long-lived process (unlikely on UDP) or if someone else snuck in a bind() call in between your two.

    Likewise, if you need the RTP port to be even, just go random for the first, and if that returns an odd port just try again – per the above, chances are the next port will be even! If not, rinse and repeat…

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

Sidebar

Related Questions

I have a RTP video stream that I want to send to a set-top
I have a bunch of RTP packets that I'd like to re-assemble into an
I need to create a WPF control that will play an rtp stream with
I have a video stream coming in on rtp to ffmpeg and I want
I'm using jmf for transmitting video stream,JPEG_RTP codec works, but rtp packet sizes too
I'm building a web app that should play back an RTSP/RTP stream from a
I wrote some code that stores on the disk some RTP packets with H264
Problem: I have to save live video streams data which come as an RTP
I have a voice chat which receives rtp packets (each packet contains 20ms of
I have implemented a raw rtp stream. I want to play it using VLC

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.