public class ClientX
extends java.lang.Object
implements java.lang.Runnable
Modifier and Type | Field and Description |
---|---|
java.io.InputStream |
input |
protected static int |
MAX_BUFFER_SIZE |
java.io.OutputStream |
output |
Constructor and Description |
---|
ClientX(java.lang.Thread parent,
java.net.Socket socket) |
ClientX(java.lang.Thread parent,
java.lang.String host,
int port) |
ClientX(java.lang.Thread parent,
java.lang.String host,
int port,
boolean b) |
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.
|
void |
initSocket() |
java.lang.String |
ip()
( begin auto-generated from Client_ip.xml )
Returns the IP address of the computer to which the Client is attached
|
int |
port() |
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 Grab whatever is in the serial buffer, and stuff it
into a byte buffer passed in by the user.
|
byte[] |
readBytes(int max)
Advanced Return a byte array of anything that's in the serial
buffer up to the specified maximum number of bytes.
|
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 Reads from the serial port into a buffer of bytes until
a particular character.
|
char |
readChar()
( begin auto-generated from Client_readChar.xml )
Returns the next byte in the buffer as a char.
|
java.lang.String |
readString()
( begin auto-generated from Client_readString.xml )
Returns the all the data from the buffer as a String.
|
java.lang.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(java.lang.String data)
Advanced Write a String to the output.
|
protected static final int MAX_BUFFER_SIZE
public java.io.InputStream input
public java.io.OutputStream output
public ClientX(java.lang.Thread parent, java.lang.String host, int port, boolean b)
public ClientX(java.lang.Thread parent, java.lang.String host, int port)
public ClientX(java.lang.Thread parent, java.net.Socket socket) throws java.io.IOException
socket
- any object of type Socketjava.io.IOException
public void initSocket() throws java.lang.Exception
java.lang.Exception
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 java.lang.Runnable
public boolean active()
public java.lang.String ip()
public int port()
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 java.lang.String readString()
public java.lang.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(java.lang.String data)