Fix jenkins
This commit is contained in:
parent
f88f5b1d40
commit
c056b083d2
6
Jenkinsfile
vendored
6
Jenkinsfile
vendored
@ -7,10 +7,10 @@
|
|||||||
sh 'javac -cp "./src" -d "./bin" $(find . -iname "*.java" -type f) -Xlint:deprecation -encoding UTF8'
|
sh 'javac -cp "./src" -d "./bin" $(find . -iname "*.java" -type f) -Xlint:deprecation -encoding UTF8'
|
||||||
sh 'echo "BUILDING CLIENT"'
|
sh 'echo "BUILDING CLIENT"'
|
||||||
sh 'echo Main-Class: clientP2P/ClientP2P > MANIFEST.MF'
|
sh 'echo Main-Class: clientP2P/ClientP2P > MANIFEST.MF'
|
||||||
sh 'jar -cvmf MANIFEST.MF client.jar $(find . \\( -iname "*.class" -and ! -iwholename "*/serverP2P/*.class" \\) -type f)'
|
sh 'jar -cvmf MANIFEST.MF client.jar $(find bin/ -maxdepth 1 -mindepth 1 -printf "-C bin %f\n")'
|
||||||
sh 'echo "BUILDING SERVER"'
|
sh 'echo "BUILDING SERVER"'
|
||||||
sh 'echo Main-Class: javaProjet2020/Server > MANIFEST.MF'
|
sh 'echo Main-Class: serverP2P/ServerP2P > MANIFEST.MF'
|
||||||
sh 'jar -cvmf MANIFEST.MF server.jar $(find . \\( -iname "*.class" -and ! -iwholename "*/clientP2P/*.class" \\) -type f)'
|
sh 'jar -cvmf MANIFEST.MF server.jar $(find bin/ -maxdepth 1 -mindepth 1 -printf "-C bin %f\n")'
|
||||||
sh 'tar -zcvf sources.tar.gz src/'
|
sh 'tar -zcvf sources.tar.gz src/'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,78 +7,82 @@ import java.net.UnknownHostException;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/** Class to store hostnames + ports
|
/** Class to store hostnames + ports
|
||||||
|
* @author Louis Royer
|
||||||
|
* @author Flavien Haas
|
||||||
|
* @author JS Auge
|
||||||
|
* @version 1.0
|
||||||
|
*/
|
||||||
|
public class HostItem {
|
||||||
|
private String hostname;
|
||||||
|
private int port;
|
||||||
|
private Socket tcpSocket;
|
||||||
|
private DatagramSocket udpSocket;
|
||||||
|
|
||||||
|
/** Constructor with hostname and port
|
||||||
|
* @param hostname Hostname
|
||||||
|
* @param port Port
|
||||||
*/
|
*/
|
||||||
public class HostItem {
|
public HostItem(String hostname, int port) {
|
||||||
private String hostname;
|
this.port = port;
|
||||||
private int port;
|
this.hostname = hostname;
|
||||||
private Socket tcpSocket;
|
|
||||||
private DatagramSocket udpSocket;
|
|
||||||
|
|
||||||
/** Constructor with hostname and port
|
|
||||||
* @param hostname Hostname
|
|
||||||
* @param port Port
|
|
||||||
*/
|
|
||||||
public HostItem(String hostname, int port) {
|
|
||||||
this.port = port;
|
|
||||||
this.hostname = hostname;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get TCP Socket.
|
|
||||||
* @return TCP Socket
|
|
||||||
*/
|
|
||||||
public Socket getTCPSocket() {
|
|
||||||
if (tcpSocket == null) {
|
|
||||||
try {
|
|
||||||
tcpSocket = new Socket(InetAddress.getByName(hostname), port);
|
|
||||||
} catch (SocketException e) {
|
|
||||||
System.err.println("Error: No TCP socket available.");
|
|
||||||
System.exit(-1);
|
|
||||||
} catch (UnknownHostException e) {
|
|
||||||
System.err.println("Error: Unknown host.");
|
|
||||||
System.exit(-1);
|
|
||||||
} catch (IOException e) {
|
|
||||||
System.err.println("Error: Cannot create TCP socket");
|
|
||||||
System.exit(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return tcpSocket;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Closes tcp socket
|
|
||||||
*/
|
|
||||||
public void closeTCPSocket() {
|
|
||||||
if (tcpSocket != null) {
|
|
||||||
try {
|
|
||||||
tcpSocket.close();
|
|
||||||
} catch (IOException e2) {
|
|
||||||
System.err.println("Error: cannot close socket");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tcpSocket = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Get UDP Socket
|
|
||||||
* return UDP Socket
|
|
||||||
*/
|
|
||||||
public DatagramSocket getUDPSocket() {
|
|
||||||
if (udpSocket == null) {
|
|
||||||
try {
|
|
||||||
udpSocket = new DatagramSocket();
|
|
||||||
udpSocket.connect(InetAddress.getByName(hostname), port);
|
|
||||||
} catch (SocketException e) {
|
|
||||||
System.err.println("Error: No UDP socket available.");
|
|
||||||
System.exit(-1);
|
|
||||||
} catch (UnknownHostException e) {
|
|
||||||
System.err.println("Error: Unknown host.");
|
|
||||||
System.exit(-1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return udpSocket;
|
|
||||||
}
|
|
||||||
public void closeUDPSocket() {
|
|
||||||
if (udpSocket != null) {
|
|
||||||
udpSocket.close();
|
|
||||||
}
|
|
||||||
udpSocket = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get TCP Socket.
|
||||||
|
* @return TCP Socket
|
||||||
|
*/
|
||||||
|
public Socket getTCPSocket() {
|
||||||
|
if (tcpSocket == null) {
|
||||||
|
try {
|
||||||
|
tcpSocket = new Socket(InetAddress.getByName(hostname), port);
|
||||||
|
} catch (SocketException e) {
|
||||||
|
System.err.println("Error: No TCP socket available.");
|
||||||
|
System.exit(-1);
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
System.err.println("Error: Unknown host.");
|
||||||
|
System.exit(-1);
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("Error: Cannot create TCP socket");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tcpSocket;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Closes tcp socket
|
||||||
|
*/
|
||||||
|
public void closeTCPSocket() {
|
||||||
|
if (tcpSocket != null) {
|
||||||
|
try {
|
||||||
|
tcpSocket.close();
|
||||||
|
} catch (IOException e2) {
|
||||||
|
System.err.println("Error: cannot close socket");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tcpSocket = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get UDP Socket
|
||||||
|
* return UDP Socket
|
||||||
|
*/
|
||||||
|
public DatagramSocket getUDPSocket() {
|
||||||
|
if (udpSocket == null) {
|
||||||
|
try {
|
||||||
|
udpSocket = new DatagramSocket();
|
||||||
|
udpSocket.connect(InetAddress.getByName(hostname), port);
|
||||||
|
} catch (SocketException e) {
|
||||||
|
System.err.println("Error: No UDP socket available.");
|
||||||
|
System.exit(-1);
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
System.err.println("Error: Unknown host.");
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return udpSocket;
|
||||||
|
}
|
||||||
|
public void closeUDPSocket() {
|
||||||
|
if (udpSocket != null) {
|
||||||
|
udpSocket.close();
|
||||||
|
}
|
||||||
|
udpSocket = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user