src/Pure/System/system_channel.scala
author wenzelm
Sat, 13 Feb 2016 20:41:56 +0100
changeset 62296 b04a5ddd6121
parent 59350 acba5d6fdb2f
child 62299 9e95a4afb8c3
permissions -rw-r--r--
clarified bash process -- similar to ML version;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
45027
f459e93a038e more abstract wrapping of fifos as System_Channel;
wenzelm
parents:
diff changeset
     1
/*  Title:      Pure/System/system_channel.scala
f459e93a038e more abstract wrapping of fifos as System_Channel;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
f459e93a038e more abstract wrapping of fifos as System_Channel;
wenzelm
parents:
diff changeset
     3
59350
acba5d6fdb2f discontinued fifo channel, always use portable socket;
wenzelm
parents: 59341
diff changeset
     4
Socket-based system channel for inter-process communication.
45027
f459e93a038e more abstract wrapping of fifos as System_Channel;
wenzelm
parents:
diff changeset
     5
*/
f459e93a038e more abstract wrapping of fifos as System_Channel;
wenzelm
parents:
diff changeset
     6
f459e93a038e more abstract wrapping of fifos as System_Channel;
wenzelm
parents:
diff changeset
     7
package isabelle
f459e93a038e more abstract wrapping of fifos as System_Channel;
wenzelm
parents:
diff changeset
     8
f459e93a038e more abstract wrapping of fifos as System_Channel;
wenzelm
parents:
diff changeset
     9
59350
acba5d6fdb2f discontinued fifo channel, always use portable socket;
wenzelm
parents: 59341
diff changeset
    10
import java.io.{InputStream, OutputStream}
45028
d608dd8cd409 alternative Socket_Channel;
wenzelm
parents: 45027
diff changeset
    11
import java.net.{ServerSocket, InetAddress}
45027
f459e93a038e more abstract wrapping of fifos as System_Channel;
wenzelm
parents:
diff changeset
    12
f459e93a038e more abstract wrapping of fifos as System_Channel;
wenzelm
parents:
diff changeset
    13
f459e93a038e more abstract wrapping of fifos as System_Channel;
wenzelm
parents:
diff changeset
    14
object System_Channel
f459e93a038e more abstract wrapping of fifos as System_Channel;
wenzelm
parents:
diff changeset
    15
{
59350
acba5d6fdb2f discontinued fifo channel, always use portable socket;
wenzelm
parents: 59341
diff changeset
    16
  def apply(): System_Channel = new System_Channel
45027
f459e93a038e more abstract wrapping of fifos as System_Channel;
wenzelm
parents:
diff changeset
    17
}
f459e93a038e more abstract wrapping of fifos as System_Channel;
wenzelm
parents:
diff changeset
    18
59350
acba5d6fdb2f discontinued fifo channel, always use portable socket;
wenzelm
parents: 59341
diff changeset
    19
class System_Channel private
45028
d608dd8cd409 alternative Socket_Channel;
wenzelm
parents: 45027
diff changeset
    20
{
d608dd8cd409 alternative Socket_Channel;
wenzelm
parents: 45027
diff changeset
    21
  private val server = new ServerSocket(0, 2, InetAddress.getByName("127.0.0.1"))
d608dd8cd409 alternative Socket_Channel;
wenzelm
parents: 45027
diff changeset
    22
54005
132640f4c453 tuned signature -- facilitate experimentation with other processes;
wenzelm
parents: 52537
diff changeset
    23
  def params: List[String] = List("127.0.0.1", server.getLocalPort.toString)
132640f4c453 tuned signature -- facilitate experimentation with other processes;
wenzelm
parents: 52537
diff changeset
    24
62296
b04a5ddd6121 clarified bash process -- similar to ML version;
wenzelm
parents: 59350
diff changeset
    25
  def prover_options: String = "-P 127.0.0.1:" + server.getLocalPort
45028
d608dd8cd409 alternative Socket_Channel;
wenzelm
parents: 45027
diff changeset
    26
d608dd8cd409 alternative Socket_Channel;
wenzelm
parents: 45027
diff changeset
    27
  def rendezvous(): (OutputStream, InputStream) =
d608dd8cd409 alternative Socket_Channel;
wenzelm
parents: 45027
diff changeset
    28
  {
d608dd8cd409 alternative Socket_Channel;
wenzelm
parents: 45027
diff changeset
    29
    val socket = server.accept
54340
18c621069bf8 prefer TCP_NODELAY -- avoid extra buffering due to Nagle's algorithm;
wenzelm
parents: 54005
diff changeset
    30
    socket.setTcpNoDelay(true)
45028
d608dd8cd409 alternative Socket_Channel;
wenzelm
parents: 45027
diff changeset
    31
    (socket.getOutputStream, socket.getInputStream)
d608dd8cd409 alternative Socket_Channel;
wenzelm
parents: 45027
diff changeset
    32
  }
d608dd8cd409 alternative Socket_Channel;
wenzelm
parents: 45027
diff changeset
    33
d608dd8cd409 alternative Socket_Channel;
wenzelm
parents: 45027
diff changeset
    34
  def accepted() { server.close }
d608dd8cd409 alternative Socket_Channel;
wenzelm
parents: 45027
diff changeset
    35
}