public class Client
extends Object
implements Runnable
Constructor and Description |
---|
Client(PApplet parent,
Socket socket) |
Client(PApplet parent,
String host,
int port) |
Modifier and Type | Method and Description |
---|---|
boolean |
active()
( begin auto-generated from Client_active.xml )
Returns true if this client is still active and hasn't run
into any trouble.
|
int |
available()
( begin auto-generated from Client_available.xml )
Returns the number of bytes available.
|
void |
clear()
( begin auto-generated from Client_clear.xml )
Empty the buffer, removes all the data stored there.
|
void |
dispose()
Disconnect from the server: internal use only.
|
String |
ip()
( begin auto-generated from Client_ip.xml )
Returns the IP address of the computer to which the Client is attached.
|
int |
read()
( begin auto-generated from Client_read.xml )
Returns a number between 0 and 255 for the next byte that's waiting in
the buffer.
|
byte[] |
readBytes()
( begin auto-generated from Client_readBytes.xml )
Reads a group of bytes from the buffer.
|
int |
readBytes(byte[] bytebuffer)
Advanced
|
byte[] |
readBytes(int max)
Advanced
|
byte[] |
readBytesUntil(int interesting)
( begin auto-generated from Client_readBytesUntil.xml )
Reads from the port into a buffer of bytes up to and including a
particular character.
|
int |
readBytesUntil(int interesting,
byte[] byteBuffer)
Advanced
|
char |
readChar()
( begin auto-generated from Client_readChar.xml )
Returns the next byte in the buffer as a char.
|
String |
readString()
( begin auto-generated from Client_readString.xml )
Returns the all the data from the buffer as a String.
|
String |
readStringUntil(int interesting)
( begin auto-generated from Client_readStringUntil.xml )
Combination of readBytesUntil() and readString().
|
void |
run() |
void |
stop()
( begin auto-generated from Client_stop.xml )
Disconnects from the server.
|
void |
write(byte[] data) |
void |
write(int data)
( begin auto-generated from Client_write.xml )
Writes data to a server specified when constructing the client.
|
void |
write(String data)
Advanced
|
public Client(PApplet parent, String host, int port)
parent
- typically use "this"host
- address of the serverport
- port to read/write from on the serverpublic Client(PApplet parent, Socket socket) throws IOException
socket
- any object of type SocketIOException
public void stop()
public void dispose()
This should only be called by the internal functions in PApplet, use stop() instead from within your own applets.
public void run()
run
in interface Runnable
public boolean active()
public String ip()
public int available()
public void clear()
public int read()
public char readChar()
public byte[] readBytes()
public byte[] readBytes(int max)
max
- the maximum number of bytes to readpublic int readBytes(byte[] bytebuffer)
bytebuffer
- passed in byte array to be alteredpublic byte[] readBytesUntil(int interesting)
interesting
- character designated to mark the end of the datapublic int readBytesUntil(int interesting, byte[] byteBuffer)
byteBuffer
- passed in byte array to be alteredpublic String readString()
public String readStringUntil(int interesting)
interesting
- character designated to mark the end of the datapublic void write(int data)
data
- data to writepublic void write(byte[] data)
public void write(String data)