Skip to content

Commit

Permalink
0.1.1
Browse files Browse the repository at this point in the history
fix socket leak
handle error of file not found
  • Loading branch information
Immueggpain authored and Immueggpain committed Dec 29, 2019
1 parent 350bfed commit e9fd430
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.github.immueggpain</groupId>
<artifactId>simple-streaming</artifactId>
<version>0.1.0</version>
<version>0.1.1</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
subcommands = { HelpCommand.class, StreamUpload.class, StreamServer.class, Serve.class })
public class Launcher implements Callable<Void> {

public static final String VERSTR = "0.1.0";
public static final String VERSTR = "0.1.1";
public static final int LOCAL_PORT = 2233;
public static final int LOCAL_OVPN_PORT = 1194;
public static final int BUFLEN = 1024 * 256;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.immueggpain.simplestreaming;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
import java.io.RandomAccessFile;
Expand All @@ -20,13 +21,13 @@ public class StreamUpload implements Callable<Void> {

@Override
public Void call() throws Exception {
try {
Socket socket = new Socket(serverName, serverPort);
try (Socket socket = new Socket(serverName, serverPort)) {

OutputStream os = socket.getOutputStream();
byte[] buf = new byte[Launcher.BUFLEN];

RandomAccessFile file = new RandomAccessFile(filepath, "r");
RandomAccessFile file;
file = new RandomAccessFile(filepath, "r");
file.seek(file.length());

try {
Expand All @@ -43,9 +44,11 @@ public Void call() throws Exception {
e.printStackTrace();
}

System.out.println("close socket");
file.close();
socket.close();

} catch (FileNotFoundException e) {
System.out.println("File not found, please start OBS and record first!");
return null;
} catch (Exception e) {
e.printStackTrace();
}
Expand Down

0 comments on commit e9fd430

Please sign in to comment.