-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathSocketUtils.java
More file actions
71 lines (59 loc) · 2 KB
/
SocketUtils.java
File metadata and controls
71 lines (59 loc) · 2 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package org.anddev.andengine.util;
import java.io.IOException;
import java.net.DatagramSocket;
import java.net.ServerSocket;
import java.net.Socket;
/**
* (c) 2010 Nicolas Gramlich
* (c) 2011 Zynga Inc.
*
* @author Nicolas Gramlich
* @since 14:42:15 - 18.09.2009
*/
public class SocketUtils {
// ===========================================================
// Constants
// ===========================================================
// ===========================================================
// Fields
// ===========================================================
// ===========================================================
// Constructors
// ===========================================================
private SocketUtils() {}
// ===========================================================
// Getter & Setter
// ===========================================================
// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================
// ===========================================================
// Methods
// ===========================================================
public static void closeSocket(final DatagramSocket pDatagramSocket) {
if(pDatagramSocket != null && !pDatagramSocket.isClosed()) {
pDatagramSocket.close();
}
}
public static void closeSocket(final Socket pSocket) {
if(pSocket != null && !pSocket.isClosed()) {
try {
pSocket.close();
} catch (final IOException e) {
Debug.e(e);
}
}
}
public static void closeSocket(final ServerSocket pServerSocket) {
if(pServerSocket != null && !pServerSocket.isClosed()) {
try {
pServerSocket.close();
} catch (final IOException e) {
Debug.e(e);
}
}
}
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
}