aboutsummaryrefslogtreecommitdiff
path: root/test/org/traccar/server/SocketCliente.java
blob: c26c02e495954bf7a0ea615662d8ab0f6d4e3161 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package org.traccar.server;

import java.io.IOException;
import java.io.PrintStream;
import java.net.Socket;

public class SocketCliente {

	/**
	 * @param args
	 */
	public void SendMSG(String url, int port, String msg) {

		Socket s = null;

		PrintStream ps = null;

		try {

			s = new Socket(url, port);

			ps = new PrintStream(s.getOutputStream());

			ps.println(msg);

			System.out.println("send");

		} catch (IOException e) {

			System.out
					.println("Some problem happened on send data to socket.");

		} finally {

			try {
				s.close();
			} catch (IOException e) {
			}

		}

	}

}