Java 8, 662 bytes
import java.io.*;import java.util.*;interface M{static void main(String[]a)throws Exception{String s="import java.io.*;import java.util.*;interface M{static void main(String[]a)throws Exception{String s=%c%s%1$c,x=s=s.format(s,34,s);for(List l=Arrays.asList(x.split(%1$c%1$c));!x.equals(s);s=s.join(%1$c%1$c,l));ObjectOutputStream o=new ObjectOutputStream(new java.net.Socket(%1$clocalhost%1$c,0).getOutputStream());o.writeObject(s);o.flush();}}",x=s=s.format(s,34,s);for(List l=Arrays.asList(x.split(""));!x.equals(s);s=s.join("",l));ObjectOutputStream o=new ObjectOutputStream(new java.net.Socket("localhost",0).getOutputStream());o.writeObject(s);o.flush();}}
Creating a quine in Java is verbose as F... >.>
Explanation:
'Try it' here. (Will result in java.net.SocketException: Permission denied
.)
import java.io.*; // Required import for ObjectOutputStream
import java.util.*; // Required import for List and Arrays
interface M{ // Class
static void main(String[]a) // Required main-method
throws Exception{ // required throws for the Stream and Socket
String s="import java.io.*;import java.util.*;interface M{static void main(String[]a)throws Exception{String s=%c%s%1$c,x=s=s.format(s,34,s);for(List l=Arrays.asList(x.split(%1$c%1$c));!x.equals(s);s=s.join(%1$c%1$c,l));ObjectOutputStream o=new ObjectOutputStream(new java.net.Socket(%1$clocalhost%1$c,0).getOutputStream());o.writeObject(s);o.flush();System.out.println(s);}}",
// Quine-String
x=s=s.format(s,34,s);for(List l=Arrays.asList(x.split(""));!x.equals(s);s=s.join("",l));
// Quine-magic
ObjectOutputStream o=new ObjectOutputStream(new java.net.Socket("localhost",0).getOutputStream());
// Output stream to http://localhost:0000/
o.writeObject(s); // Write to the output stream
o.flush(); // And send it
} // End of main-method
} // End of class
- The String
s
contains the unformatted source code.
%s
is used to input this String into itself with the s.format(...)
.
%c
, %1$c
and the 34
are used to format the double-quotes.
s.format(s,34,s)
puts it all together
Slightly modified with print
to prove it's a quine:
Try it here.
Is there a specific host we need to send to? – Kevin Cruijssen – 2017-07-03T07:23:02.453
@KevinCruijssen you can use any, but it will be able to recive message – Евгений Новиков – 2017-07-03T07:24:41.327
Could you give a valid example-host? – Kevin Cruijssen – 2017-07-03T07:43:06.953
1@KevinCruijssen localhost – Евгений Новиков – 2017-07-03T07:52:18.113
5
This seems like the kind of generalised quine where the quine part adds nothing to the networking part and the networking part adds nothing to the quine part.
– Martin Ender – 2017-07-03T08:12:32.697does unclear means boring? – Евгений Новиков – 2017-07-03T14:12:10.933