Wish Ethernet Client/Server

Erel

B4X founder
Staff member
Licensed User
Longtime User
It already supports it.

For example to connect to www.example.com:
B4X:
Sub Connect(unused As Byte)
   If ethClient.ConnectHost("example.com", 80) = False Then
     Log("trying to connect again")
     CallSubPlus("Connect", 1000, 0)
     Return
   End If
   Log("Connected to server")
   astream.Initialize(ethClient.Stream, "Astream_NewData", "Astream_Error")
   Dim eol() As Byte = Array As Byte(13, 10)
   astream.Write("GET / HTTP/1.1".GetBytes)
   astream.Write(eol)
  astream.Write("Host: www.example.com".GetBytes)
   astream.Write(eol)
  astream.Write("Connection: close".GetBytes)
   astream.Write(eol)
   astream.Write(eol)
End Sub

ConnectHost method will be included in the next update. You can replace it with:
B4X:
ethClient.ConnectIP(Array As Byte(93, 184, 216, 34), 80)

As I see it if you want to implement a web server then you should use Raspberry Pi with a real B4J server.
 
Top