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

rEthernet

List of types:

Ethernet
EthernetServerSocket
EthernetSocket
EthernetUDP

Ethernet


Events:

None

Members:


  Initialize (MacAddress() As Byte, LocalIp() As Byte) As void

  InitializeDHCP (MacAddress() As Byte) As Boolean

  LocalIp As String [read only]

  MaintainDHCP As Byte

Members description:

Initialize (MacAddress() As Byte, LocalIp() As Byte) As void
Initializes the shield with a static ip address.
InitializeDHCP (MacAddress() As Byte) As Boolean
Initializes the ethernet connection.
Gets the local ip address from the DHCP service.
Returns true if the ip address was assigned successfully.
MacAddress - The shield mac address.

Example:
eth.InitializeDHCP(Array As Byte(0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED))
LocalIp As String [read only]
Returns the local ip address as a string.
MaintainDHCP As Byte
Allows for the renewal of DHCP leases. This method should be called approximately
every second when the the ethernet was initialized with InitializeDHCP.

EthernetServerSocket

A server socket implementation.

Events:

NewConnection (NewSocket As EthernetSocket)

Members:


  Initialize (Port As UInt, NewConnectionSub As SubVoidEthernetSocket) As void

  Listen As void

  Socket As EthernetSocket [read only]

Members description:

Initialize (Port As UInt, NewConnectionSub As SubVoidEthernetSocket) As void
Initializes the server.
Port - The server port.
NewConnectionSub - The sub that will handle the NewConnection event.
Listen As void
Starts listening for connections.
The NewConnection event will be raised when data from the new client is available.
This means that the client is expected to send at least one byte after the connection is established.
You should call Listen again after the connection has broken. AsyncStreams_Error is a good place for this call.
Socket As EthernetSocket [read only]
Returns the last connected socket.

EthernetSocket

A client socket implementation.

Events:

None

Members:


  Close As void

  Connected As Boolean [read only]

  ConnectHost (Host As String, Port As UInt) As Boolean

  ConnectIP (IP() As Byte, Port As UInt) As Boolean

  Stream As B4RStream [read only]

Members description:

Close As void
Closes the connection.
Connected As Boolean [read only]
Tests whether the client is connected.
ConnectHost (Host As String, Port As UInt) As Boolean
Tries to connect to the server. Returns true if connection was successful.
Host - Host name.
Port - Server port.
ConnectIP (IP() As Byte, Port As UInt) As Boolean
Tries to connect to the server. Returns true if connection was successful.
IP - Server ip address as an array of bytes.
Port - Server port.
Stream As B4RStream [read only]
Gets the network stream. Can be used together with AsyncStreams.

EthernetUDP

Allows receiving and sending UDP packets.

Events:

PacketArrived (Data() As Byte, IP() As Byte, Port As UInt)

Members:


  BeginPacket (IP() As Byte, Port As UInt) As Boolean

  Close As void

  Initialize (Port As UInt, PacketArrivedSub As SubPacketArrived) As Boolean

  SendPacket As Boolean

  Write (Data() As Byte) As Int

Members description:

BeginPacket (IP() As Byte, Port As UInt) As Boolean
Starts sending a packet. The packet will be sent when SendPacket is called.
IP - Target ip address.
Port - Target port address.
Close As void
Closes the socket.
Initialize (Port As UInt, PacketArrivedSub As SubPacketArrived) As Boolean
Initializes the object. Returns True if successful.
Port - The UDP socket will be bound to this port.
PacketArrivedSub - The sub that handles the PacketArrived event.
SendPacket As Boolean
Sends the packet.
Write (Data() As Byte) As Int
Writes data to the packet. Returns the number of bytes that were written successfully.
This method should only be called between a call to BeginPacket and SendPacket.
You can call Write multiple times.
Top