View Javadoc

1   /*
2     The TauP Toolkit: Flexible Seismic Travel-Time and Raypath Utilities.
3     Copyright (C) 1998-2000 University of South Carolina
4   
5     This program is free software; you can redistribute it and/or
6     modify it under the terms of the GNU General Public License
7     as published by the Free Software Foundation; either version 2
8     of the License, or (at your option) any later version.
9   
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14  
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18  
19    The current version can be found at
20    <A HREF="www.seis.sc.edu">http://www.seis.sc.edu</A>
21  
22    Bug reports and comments should be directed to
23    H. Philip Crotwell, crotwell@seis.sc.edu or
24    Tom Owens, owens@seis.sc.edu
25  
26  */
27  
28  package edu.sc.seis.TauP;
29  
30  import java.io.DataInputStream;
31  import java.io.DataOutputStream;
32  import java.io.IOException;
33  import java.net.Socket;
34  
35  /*** example TauP client. Connects to the TauPDaemon and calculates times.
36    *
37    * @version 1.1.3 Wed Jul 18 15:00:35 GMT 2001
38  
39  
40  
41    * @author H. Philip Crotwell
42    *
43    */
44  public class TauPClient {
45  
46      public static void main(String[] args) {
47          DataInputStream fromServer;
48          DataOutputStream toServer;
49          try {
50              Socket timeSocket = new Socket("localhost", 6371, true);
51              fromServer = new DataInputStream(timeSocket.getInputStream());
52              toServer =  new DataOutputStream(timeSocket.getOutputStream());
53              
54              toServer.writeBytes("MODEL prem\n");
55              toServer.writeBytes("PHASES P,S\n");
56              toServer.writeBytes("DEPTH 100.0\n");
57              toServer.writeBytes("DISTANCE 60.0\n");
58              String outString;
59              while ((outString = fromServer.readLine()) != null) {
60                  System.out.println(outString);
61              }
62          } catch (IOException e) {
63          }
64          
65      }
66  }