You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: java/libraries/net/src/processing/net/Server.java
+14-28Lines changed: 14 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -31,15 +31,11 @@
31
31
importjava.net.*;
32
32
33
33
/**
34
-
* A server sends and receives data to and from its associated clients (other programs connected to it).
35
-
* When a server is started, it begins listening for connections on the port specified by the <b>port</b> parameter.
36
-
* Computers have many ports for transferring data and some are commonly used so be sure to not select one of these.
37
-
* For example, web servers usually use port 80 and POP mail uses port 110.
38
-
*
39
-
* @webref
34
+
* @generate Server.xml
35
+
* @webref net
36
+
* @usage application
40
37
* @brief The server class is used to create server objects which send and receives data to and from its associated clients (other programs connected to it).
41
38
* @instanceName server any variable of type Server
42
-
* @usage Application
43
39
*/
44
40
publicclassServerimplementsRunnable {
45
41
@@ -95,8 +91,8 @@ public Server(PApplet parent, int port) {
95
91
96
92
97
93
/**
98
-
* Disconnect a particular client.
99
-
* @webref
94
+
* @generate Server_disconnect.xml
95
+
* @webref server:server
100
96
* @param client the client to disconnect
101
97
*/
102
98
publicvoiddisconnect(Clientclient) {
@@ -144,8 +140,9 @@ protected int clientIndex(Client client) {
144
140
intlastAvailable = -1;
145
141
146
142
/**
147
-
* Returns the next client in line with a new message
148
-
* @webref
143
+
* @generate Server_available.xml
144
+
* @webref server
145
+
* @usage application
149
146
*/
150
147
publicClientavailable() {
151
148
synchronized (clients) {
@@ -166,13 +163,14 @@ public Client available() {
166
163
167
164
168
165
/**
169
-
* Disconnects all clients and stops the server
170
-
* =advanced
166
+
* @generate Server_stop.xml
167
+
* <h3>Advanced</h3>
171
168
* <p/>
172
169
* Use this to shut down the server if you finish using it while your applet
173
170
* is still running. Otherwise, it will be automatically be shut down by the
174
171
* host PApplet using dispose(), which is identical.
175
-
* @webref
172
+
* @webref server
173
+
* @usage application
176
174
*/
177
175
publicvoidstop() {
178
176
dispose();
@@ -236,10 +234,8 @@ public void run() {
236
234
237
235
238
236
/**
239
-
* Write a value to all the connected clients.
240
-
* See Client.write() for operational details.
241
-
*
242
-
* @webref
237
+
* @generate Server_write.xml
238
+
* @webref server
243
239
* @brief Writes data to all connected clients
244
240
* @param data data to write
245
241
*/
@@ -255,11 +251,6 @@ public void write(int data) { // will also cover char
255
251
}
256
252
}
257
253
258
-
259
-
/**
260
-
* Write a byte array to all the connected clients.
261
-
* See Client.write() for operational details.
262
-
*/
263
254
publicvoidwrite(bytedata[]) {
264
255
intindex = 0;
265
256
while (index < clientCount) {
@@ -272,11 +263,6 @@ public void write(byte data[]) {
0 commit comments