-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessageTrasmitter.java
More file actions
41 lines (36 loc) · 1.06 KB
/
MessageTrasmitter.java
File metadata and controls
41 lines (36 loc) · 1.06 KB
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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mychatapp.networking;
import java.io.IOException;
import java.net.Socket;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author DAIYAMONDO_NTHN
*/
public class MessageTrasmitter extends Thread{
String message,hostname;
int port;
public MessageTrasmitter(){
}
public MessageTrasmitter(String message,String hostname,int port){
this.message=message;
this.hostname=hostname;
this.port=port;
}
//receve and show message
@Override
public void run() {
try {
Socket s=new Socket(hostname,port);
s.getOutputStream().write(message.getBytes());
s.close();
} catch (IOException ex) {
Logger.getLogger(MessageTrasmitter.class.getName()).log(Level.SEVERE, null, ex);
}
}
}