Java control IP TTL?

In Java, is there a way to control the TTL of the IP header for packets sent on a socket?

Asked by: John943 | Posted: 23-01-2022

Answer 1

Apparently only on Multicast sockets, which have:

MulticastSocket.setTimeToLive(int ttl);

Answered by: Thomas330 | Posted: 24-02-2022

Answer 2

Setting the TTL using

MulticastSocket.setTimeToLive(int ttl);

is only going to work if you have enabled the IPV4Stack as outlined by this other question

Java Multicast Time To Live is always 0

Answered by: Carlos206 | Posted: 24-02-2022

Similar questions

sockets - How to resolve a Stream Closed Error in java?

I am really thankful for everyone who would read this and try to help me, the following is the code I am trying to write for a server class for a socket-programming project for college: import*; import*; import; class Server{ public static void main (String[]args)throws IOException{ ServerSocket socket1 = new ServerSocket (8000); while (true) { ...

How do you get Java sockets working with public IPs?

I have had no trouble getting the sockets working with localips, but once I made the code change to use public ips, I've consistently gotten I am using the port 8084, which as far as I know, is not used elsewhere In the command prompt, netstat -a | grep 8084 shows: File STDIN: TCP user-9114eb19a8:8084 user-9114eb19a8:0 LISTENING I have gone into my router and ensured ...

Java sockets with out of band data

Does anybody know how to receive (how to know that you received) out-of-band data with Java sockets? In particular I've read the documentation for sendUrgentData and setOOBInline whi...

java - Server and Client using Sockets

Are there any examples of a server and a client that use sockets, but that have send and get methods? I'm doing this networked battleship program, almost finished, but can't get the server and clients to work. I have made a chat program that only sends strings, but this time I need to send objects. I'm already frustrated, so is there any source code that already has this. Here's the code for the client... how wo...

Java sockets and TCP tuning

I try to develop a file transfer application in Java, with an applet as client, and a standalone java app as server (on a dedicated machine hosted in a datacenter). I use DataOutputStream/DataInputStream to transfers the data on both sides. When I send big volumes of data, the bandwith is very variable : all is okay first, then the tcp stream is freezed during 40-50 seconds while nothing is transferring, and then it starts...

sockets - Java Chat Server

FYI This is homework. I have to build a Java Chat server. I have been able to build a server which communicates with 1 client. But I need this to communicate with multiple users. A user is supposed to type in the person's name they wish to talk to followed by a dash (-) and then the message to be sent. I am able to get users signed on but I am not able to get the list of users to print out or the messages to send t...

Java Sockets over WLAN?

I have 2 windows PC's connected over an ad-hoc wlan network. Using this existing connection can I communicate between these pc's via sockets? Can I open a server socket on one pc and make the other pc a client and connect to the other pc and then send and receive data over this connection? Do I need a specific api for this or can I just use and

Is it possible to close Java sockets on both client and server sides?

I have a socket tcp connection between two java applications. When one side closes the socket the other side remains open. but I want it to be closed. And also I can't wait on it to see whether it is available or not and after that close it. I want some way to close it completely from one side. What can I do?

sockets - Java Server Help!

I've followed a tutorial to create the socket server below which allows multiple users to connect and if they send some data to it then it returns it back to them. import java.awt.Color; import java.awt.BorderLayout; import java.awt.event.*; import javax.swing.*; import*; import*; class ClientWorker implements Runnable { private Socket client; priv...

sockets - Add HEADER in HTTP Request in Java

I'm using this following code to send simple HTTP Request : try { Socket s = new Socket (); s.bind (new InetSocketAddress (ipFrom, 0)); s.connect (new InetSocketAddress (ipTo, 80), 1000); PrintWriter writer = new PrintWriter (s.getOutputStream ()); BufferedReader reader = new BufferedReader (new InputStreamReader (s.getInputStream ())); writer.print ("GET " +...

Still can't find your answer? Check out these amazing Java communities for help...

Java Reddit Community | Java Help Reddit Community | Java Community | Java Discord | Java Programmers (Facebook) | Java developers (Facebook)