Android Programming Press on the image to return to the main documentation page.

iNetwork

List of types:

ServerSocket
Socket
UDPPacket
UDPSocket

ServerSocket


Events:

NewConnection (Successful As Boolean, NewSocket As Socket)

Members:


  Close

  GetMyIP As String

  GetMyWifiIp As String

  Initialize (Port As Int, EventName As String)

  IsInitialized As Boolean

  Listen

Members description:

Close
Closes the ServerSocket.
GetMyIP As String
Returns the device IP address. Preferably the wifi address. Returns 127.0.0.1 if there is no ip address.
GetMyWifiIp As String
Returns the wifi address. Returns 127.0.0.1 if there is no ip address.
Initialize (Port As Int, EventName As String)
Initializes the server socket and binds it to the given port.
IsInitialized As Boolean
Listen
Starts listening for incoming connections. The NewConnection event will be raised when there is a new connection.
Calling Listen when the server is already listening will not do anything.

Socket


Events:

Connected (Successful As Boolean)

Members:


  Close

  Connect (Host As String, Port As Int, Timeout As Int)

  Connected As Boolean [read only]

  Initialize (EventName As String)

  InputStream As InputStream [read only]

  IsInitialized As Boolean

  OutputStream As OutputStream [read only]

  Timeout As Int

Members description:

Close
Closes the socket and the streams. It is safe to call this method multiple times.
Connect (Host As String, Port As Int, Timeout As Int)
Tries to to connect to the given address. The Connected event will be raised when operation completes.
Host - The host name or ip address.
Port - Port number.
Timeout - Connection timeout measured in milliseconds. Pass 0 to disable the timeout.
Connected As Boolean [read only]
Returns true if the socket is connected.
Initialize (EventName As String)
InputStream As InputStream [read only]
Gets the network input stream. In most cases the stream should be passed to an AsyncStreams object.
IsInitialized As Boolean
OutputStream As OutputStream [read only]
Gets the network output stream. In most cases the stream should be passed to an AsyncStreams object.
Timeout As Int
Gets or sets the socket timeout, measured in milliseconds.
By default there is no timeout.

UDPPacket


Events:

None

Members:


  Data() As Byte [read only]

  HostAddress As String [read only]

  Initialize (Data() As Byte, Host As String, Port As Int)

  Initialize2 (Data() As Byte, Offset As Int, Length As Int, Host As String, Port As Int)

  Length As Int [read only]

  Offset As Int [read only]

  Port As Int [read only]

Members description:

Data() As Byte [read only]
Gets the data.
HostAddress As String [read only]
Gets the IP address of the other socket.
Initialize (Data() As Byte, Host As String, Port As Int)
Initializes the packet with the given data and destination.
You can reuse the buffer after this call (data is copied).
Initialize2 (Data() As Byte, Offset As Int, Length As Int, Host As String, Port As Int)
Same as Initialize. The data is sent based on the given offset and length.
Length As Int [read only]
Gets the data length.
Offset As Int [read only]
Gets the received data offset.
Port As Int [read only]
Gets the port of the other socket.

UDPSocket

UDPSocket supports sending and receiving UDPPackets.

Events:

PacketArrived(Packet As UDPPacket)

Members:


  Close

  GetBroadcastAddress As String

  Initialize (EventName As String, Port As Int, ReceiveBufferSize As Int)

  IsInitialized As Boolean

  Send (Packet As UDPPacket)

Members description:

Close
Closes the socket/
GetBroadcastAddress As String
Returns the network broadcast address.
Initialize (EventName As String, Port As Int, ReceiveBufferSize As Int)
Initializes the socket and starts listening for packets.
EventName - Sets the sub that will handle the PacketArrived event.
Port - Local port to listen on. Pass 0 to let the OS choose an available port.
ReceiveBufferSize - The maximum size of received packets. Pass 0 if the socket should not listen to incoming packets.
IsInitialized As Boolean
Send (Packet As UDPPacket)
Sends the packet.
Top