java - Is it possible to send broadcast socket in jsp? -


I get the jsp code for socket send and change the IP to 255.255.255.255, but the result is Is: Network is not accessible '.

The code is:

  & lt;% @ page content type = "text / html; charset = utf-8" language = "java" import = "java. Util. *, Java.net. *, Java.io. *, Java.lang. * "ErrorPage =" "%> Var Errors = ""; & Lt;% attempt {int characters; Socket socket = new socket ("255.255.255.255", 10000); InputStream inSocket = socket.getInputStream (); OutputStream Outsocket = Socket.GetOutputTream (); String str = "message"; Byte buffer [] = str.getBytes (); OutSocket.write (buffer); While ((character = inSocket.read ())! = -1) {out.print ((four characters)); } Socket.close (); } Hold (java.lang.Exception e) {%> Errors = "Something is wrong!" + "& Lt;% = e.getMessage ()%>"; I have Tomcat 6 version (I think ...), or if this is impossible (I have heard that people say that JSP is different from Java, it is only used for presentation ), Can I write Java class (using datagram socket) to show the data I get and import my JSP class and get data?  

Any advice would be appreciated.

You say that you have seen the link, but I think that you have not read carefully or at least you understand it Have not been found.

I will try to explain: When you make a socket with the new socket (...) you create a TCP socket. TCP is a Connect Protocol and you can not broadcast via TCP

, so fix your code using UDP socket ( DatagramSocket ), make sure that you enter < Code> socket.setBroadcast

And if it still does not work then it is worth explaining the remaining problems.

I do not enter any code here because all relevant codes are in all referenced posts.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -