Network
The Network library makes it possible to read and write data across machines on the Internet. It allows the creation clients and servers. A server connects to a list of clients for reading and writing data. A client is able to read and write data to a server.
The source code is available on the Processing GitHub repository. Please report bugs here.
Client
- Client
The client class is used to create client Objects which connect to a server to exchange data
- active()
Returns true if this client is still active
- available()
Returns the number of bytes in the buffer waiting to be read
- clear()
Clears the buffer
- ip()
Returns the IP address of the machine as a String
- read()
Returns a value from the buffer
- readBytes()
Reads a group of bytes from the buffer
- readBytesUntil()
Reads from the buffer of bytes up to and including a particular character
- readChar()
Returns the next byte in the buffer as a char
- readString()
Returns the buffer as a String
- readStringUntil()
Returns the buffer as a String up to and including a particular character
- stop()
Disconnects from the server
- write()
Writes bytes, chars, ints, bytes[], Strings
Server
- Server
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)
- active()
Return true if this server is still active
- available()
Returns the next client in line with a new message
- disconnect()
Disconnect a particular client
- stop()
Disconnects all clients and stops the server
- write()
Writes data to all connected clients
NetworkEvents
- clientEvent()
This function is called when a server sends a value to an existing Client object.
- disconnectEvent()
This function is called when a client disconnects.
- serverEvent()
The code inside serverEvent() is run when a new client connects to a server that has been created within the program.