-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSock.java
38 lines (32 loc) · 822 Bytes
/
Sock.java
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
import java.io.*;
import java.net.*;
public class Sock
{
Socket socket;
BufferedReader plec;
PrintWriter pred;
static final int port = 6667;
public Sock(String server)
throws Exception
{
this.socket = new Socket(server,this.port);
System.out.println("Creation de la socket en cours ...");
System.out.println(socket);
this.plec = new BufferedReader(new InputStreamReader(socket.getInputStream()));
this.pred = new PrintWriter(new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())),true);
}
public void initConnection(String nick)
{
this.pred.println("NICK "+nick);
this.pred.println("USER superbotte 8 x : Nacos Slave");
}
public String receive()
throws Exception
{
return this.plec.readLine();
}
public void send(String message)
{
this.pred.println(message);
}
}