agjava.net
Class Network

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--agjava.net.Network
All Implemented Interfaces:
java.lang.Runnable

public class Network
extends java.lang.Thread


Field Summary
 java.net.Socket clientSocket
           
 boolean connected
           
 java.lang.String Host
           
 java.io.DataInputStream Recv
           
 java.io.DataOutputStream Send
           
 java.net.ServerSocket serverSocket
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Network(int Port)
          Constructor Detail: Port: Local Port (Used to Bind/Listen Methods)
Network(java.lang.String Host, int Port)
          Constructor Detail: Host: Remote Host to connect.
 
Method Summary
 void Bind()
          Bind to local Port
 java.net.Socket BindListen()
          Bind to local Port and wait connection.
 void close()
          Close Socket.
 java.net.Socket Connect()
          Start Connection
static java.lang.String getHostID()
          Return local IP Address.
 java.net.Socket Listen()
          Listen Port and return Socket from connected client.
 int readByte()
          Receive a Byte value(1 Byte)
 int readInt()
          Receive a Int value(4 Bytes)
 long readLong()
          Receive a Long value(8 Bytes)
 int readShort()
          Receive a Short value(2 Bytes)
 java.lang.String readString(int packetSize)
          Receive a String data with specified size.
 void send(byte data)
          Send a Byte value(1 Byte)
 void send(int data)
          Send a Int value(4 Bytes)
 void send(long data)
          Send a Long value(8 Bytes)
 void send(short data)
          Send a Short value(2 Bytes)
 void send(java.lang.String data)
          Send a String data
 java.net.ServerSocket serverSocket()
          Return Local ServerSocket from Bind Method.
 java.net.Socket socket()
          Return Local Socket
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

clientSocket

public java.net.Socket clientSocket

connected

public boolean connected

Host

public java.lang.String Host

Recv

public java.io.DataInputStream Recv

Send

public java.io.DataOutputStream Send

serverSocket

public java.net.ServerSocket serverSocket
Constructor Detail

Network

public Network(int Port)
Constructor Detail: Port: Local Port (Used to Bind/Listen Methods)

Network

public Network(java.lang.String Host,
               int Port)
Constructor Detail: Host: Remote Host to connect. Port: Remote Port to connect.
Method Detail

Bind

public void Bind()
Bind to local Port

BindListen

public java.net.Socket BindListen()
Bind to local Port and wait connection. Return client Socket and close Bind port.

close

public void close()
Close Socket.

Connect

public java.net.Socket Connect()
Start Connection

getHostID

public static final java.lang.String getHostID()
Return local IP Address.

Listen

public java.net.Socket Listen()
Listen Port and return Socket from connected client.

readByte

public int readByte()
Receive a Byte value(1 Byte)

readInt

public int readInt()
Receive a Int value(4 Bytes)

readLong

public long readLong()
Receive a Long value(8 Bytes)

readShort

public int readShort()
Receive a Short value(2 Bytes)

readString

public java.lang.String readString(int packetSize)
Receive a String data with specified size.

send

public void send(byte data)
Send a Byte value(1 Byte)

send

public void send(int data)
Send a Int value(4 Bytes)

send

public void send(long data)
Send a Long value(8 Bytes)

send

public void send(short data)
Send a Short value(2 Bytes)

send

public void send(java.lang.String data)
Send a String data

serverSocket

public final java.net.ServerSocket serverSocket()
Return Local ServerSocket from Bind Method.

socket

public final java.net.Socket socket()
Return Local Socket