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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:32:48+00:00 2026-06-14T18:32:48+00:00

So I am currently working on a client application that listens on port 5004

  • 0

So I am currently working on a client application that listens on port 5004 for RTP packets. Since there may be multiple servers sending RTP packets, I can’t use sockets to connect to a specific remote host. Instead, I have tried the following to listen on a local port:

Socket socket = new Socket("127.0.0.1", 5004);
Socket socket = new Socket("localhost", 5004);
Socket socket = new Socket(InetAddress.getByName("localhost"), 5004);
Socket socket = new Socket(InetAddress.getLocalHost(), 5004);

Any of the above will give me this exception:

java.net.ConnectException: Connection refused: connect

I have also tried using a DatagramSocket, but DatagramPackets require that I specify the size of the packet to be read.

To summarize, I need to find a way to listen on local port 5004 for RTP packets of unknown size without connecting to a specific remote host/address. Any help is greatly appreciated!

EDIT:

I now have a ServerSocket set up to listen for connections, but I still can’t manage to read in any packets.

try {   ServerSocket server = new ServerSocket(5004);
        Socket s = server.accept();
        BufferedReader rtpReader = new BufferedReader(new InputStreamReader(s.getInputStream()));
        while (true){
            int k = rtpReader.read();
            if (k == -1) break;
            System.out.println(k);
        }
}

Note: The RTP packets are sent over a Multicast address.

The problem turned out to be the Multicast. Refer to Nikolai’s answer. Thanks alot!

  • 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-14T18:32:50+00:00Added an answer on June 14, 2026 at 6:32 pm

    You have to use java.net.MulticastSocket, and join the multicast group. Something like:

    // put your multicast address here
    InetAddress group = InetAddress.getByName( "244.10.10.10" );
    MulticastSocket sock = new MulticastSocket( 5004 );
    sock.joinGroup( group );
    
    byte[] buf = new byte[1472];
    DatagramPacket pack = new DatagramPacket( buf, buf.length );
    
    while ( whatever ) {
        sock.receive( pack );
        // handle data
    }
    
    sock.leaveGroup( group );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am currently working on an iPad application, my client wants to add Function
I'm currently working on a project that has a sizable amount of both client
I am currently working on an application for a client, and they have made
I'm currently working on a web application that might need to push information to
I am currently working on an application that should be able to detect wifi
I'm currently working on implementing a Dropbox OAuth client for my application. It's been
I am currently working on a c# .NET desktop application that will be communicating
I'm currently developing a PHP application that is going to use websockets for client-server
I'm currently working on a java application. It's a standalone client with Spring and
So, I've been working on an application for a client that communicates with wireless

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.