Skip to content

Commit 98ea52c

Browse files
committed
Update version to 1.0.2
1 parent 800c532 commit 98ea52c

File tree

4 files changed

+96
-119
lines changed

4 files changed

+96
-119
lines changed

README.md

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -83,56 +83,20 @@ public class CommunicationServer extends CoolSocket
8383
}
8484
```
8585

86-
<h3>Implement CoolSocket</h3>
87-
<h4>Maven</h4>
88-
89-
```xml
90-
...
91-
<profiles>
92-
<profile>
93-
<repositories>
94-
<repository>
95-
<snapshots>
96-
<enabled>false</enabled>
97-
</snapshots>
98-
<id>bintray-genonbeta-coolsocket</id>
99-
<name>bintray</name>
100-
<url>https://dl.bintray.com/genonbeta/coolsocket</url>
101-
</repository>
102-
</repositories>
103-
<pluginRepositories>
104-
<pluginRepository>
105-
<snapshots>
106-
<enabled>false</enabled>
107-
</snapshots>
108-
<id>bintray-genonbeta-coolsocket</id>
109-
<name>bintray-plugins</name>
110-
<url>https://dl.bintray.com/genonbeta/coolsocket</url>
111-
</pluginRepository>
112-
</pluginRepositories>
113-
<id>bintray</id>
114-
</profile>
115-
</profiles>
116-
<activeProfiles>
117-
<activeProfile>bintray</activeProfile>
118-
</activeProfiles>
119-
</profiles
120-
...
121-
```
122-
86+
<h3>Implementing CoolSocket</h3>
12387
<h4>Gradle</h4>
12488

12589
```xml
12690
...
12791
repositories {
12892
...
129-
maven { url "https://dl.bintray.com/genonbeta/coolsocket" }
93+
jcenter()
13094
...
13195
}
13296
...
13397
dependencies {
13498
...
135-
implementation 'com.genonbeta.coolsocket:main:1.0'
99+
implementation 'com.genonbeta.coolsocket:main:1.0.2'
136100
...
137101
}
138102
...

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.genonbeta.coolsocket</groupId>
88
<artifactId>main</artifactId>
9-
<version>1.0.1.5</version>
9+
<version>1.0.2</version>
1010
<name>CoolSocket</name>
1111
<description>Socket implementation</description>
1212
<url>https://github.com/genonbeta/CoolSocket</url>

src/main/java/com/genonbeta/CoolSocket/CoolSocket.java

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ public boolean startDelayed(int timeout)
253253
}
254254

255255
// ensures the server is started otherwise returns false
256-
public boolean startEnsured(int timeout) {
256+
public boolean startEnsured(int timeout)
257+
{
257258
long startTime = System.currentTimeMillis();
258259

259260
if (!this.startDelayed(timeout))
@@ -302,9 +303,19 @@ public static class ActiveConnection
302303
private int mTimeout = NO_TIMEOUT;
303304
private int mId = getClass().hashCode();
304305

306+
public ActiveConnection()
307+
{
308+
this(new Socket());
309+
}
310+
311+
public ActiveConnection(int timeout)
312+
{
313+
this(new Socket(), timeout);
314+
}
315+
305316
public ActiveConnection(Socket socket)
306317
{
307-
this.mSocket = socket;
318+
mSocket = socket;
308319
}
309320

310321
public ActiveConnection(Socket socket, int timeout)
@@ -313,6 +324,17 @@ public ActiveConnection(Socket socket, int timeout)
313324
setTimeout(timeout);
314325
}
315326

327+
public ActiveConnection connect(SocketAddress socketAddress) throws IOException
328+
{
329+
if (getTimeout() != NO_TIMEOUT)
330+
getSocket().setSoTimeout(getTimeout());
331+
332+
getSocket().bind(null);
333+
getSocket().connect(socketAddress);
334+
335+
return this;
336+
}
337+
316338
@Override
317339
protected void finalize() throws Throwable
318340
{
@@ -344,7 +366,7 @@ public Socket getSocket()
344366
return this.mSocket;
345367
}
346368

347-
public long getTimeout()
369+
public int getTimeout()
348370
{
349371
return mTimeout;
350372
}
@@ -488,15 +510,13 @@ public static class Client
488510

489511
public ActiveConnection connect(SocketAddress socketAddress, int operationTimeout) throws IOException
490512
{
491-
Socket socket = new Socket();
492-
493-
if (operationTimeout != NO_TIMEOUT)
494-
socket.setSoTimeout(operationTimeout);
495-
496-
socket.bind(null);
497-
socket.connect(socketAddress);
513+
return new ActiveConnection(operationTimeout)
514+
.connect(socketAddress);
515+
}
498516

499-
return new ActiveConnection(socket, operationTimeout);
517+
public void connect(ActiveConnection connection, SocketAddress socketAddress) throws IOException
518+
{
519+
connection.connect(socketAddress);
500520
}
501521

502522
public Object getReturn()

0 commit comments

Comments
 (0)