@@ -13,16 +13,23 @@ Running the Example
1313
1414There's a simple chat server and client example located in the ` example `
1515folder. First, compile the example classes and JAR file:
16- ant
16+
17+ ``` shell
18+ ant
19+ ```
1720
1821Then, start the chat server (a ` WebSocketServer ` subclass):
1922
20- java -cp example:dist/WebSocket.jar ChatServer
23+ ``` shell
24+ java -cp example:dist/WebSocket.jar ChatServer
25+ ```
2126
2227Now that the server is started, we need to connect some clients. Run the
2328Java chat client (a ` WebSocketClient ` subclass):
2429
25- java -cp example:dist/WebSocket.jar ChatClient
30+ ``` shell
31+ java -cp example:dist/WebSocket.jar ChatClient
32+ ```
2633
2734The chat client is a simple Swing GUI application that allows you to send
2835messages to all other connected clients, and receive messages from others in a
@@ -57,20 +64,25 @@ Testing in Android Emulator
5764Please note Android Emulator has issues using ` IPv6 addresses ` . Executing any
5865socket related code (like this library) inside it will address an error
5966
60- java.net.SocketException: Bad address family
67+ ``` shell
68+ java.net.SocketException: Bad address family
69+ ```
6170
6271You have to manually disable ` IPv6 ` by calling
63-
64- java.lang.System.setProperty("java.net.preferIPv6Addresses", "false");
65- java.lang.System.setProperty("java.net.preferIPv4Stack", "true");
72+
73+ ``` java
74+ java.lang. System . setProperty(" java.net.preferIPv6Addresses" , " false" );
75+ java.lang. System . setProperty(" java.net.preferIPv4Stack" , " true" );
76+ ```
6677
6778somewhere in your project, before instantiating the ` WebSocketClient ` class.
6879You can check if you are currently testing in the Android Emulator like this
69-
70- if ("google_sdk".equals( Build.PRODUCT ))
71- {
72- ... disable IPv6
73- }
80+
81+ ``` java
82+ if (" google_sdk" . equals( Build . PRODUCT )) {
83+ // ... disable IPv6
84+ }
85+ ```
7486
7587
7688License
0 commit comments