Networking assistance please....

PaulR

Active Member
Licensed User
Longtime User
Hi,

I am running the networking tutorials on my HTC Sensation, but they are not connecting with the server running on my PC (an audio app called Reaper).

I am using the code from this Network tutorial and this AsyncStreams tutorial.

Basically, neither of them are making a connection. Sub ServerNewConnection is never called and Async.IsInitialized is always false in the AsyncStreams one. In the Network one, Socket1_Connected is always false.

I could do with a nudge in the right direction with this. I've disabled the Windows 7 (x64) firewall and allowed port forwarding on the relevant port in my router (just in case).

Are there any simple server apps available for the PC that anyone uses that can definitely be connected to with the tutorial code or am I missing something completely obvious?

Cheers

Paul

edit:

I think it's might not be connecting because the server is using UDP. I am trying out this code from the documentation....
B4X:
Sub Process_Globals
    Dim UDPSocket1 As UDPSocket
End Sub

Sub Globals
End Sub

Sub Activity_Create(FirstTime As Boolean)
    If FirstTime Then
        UDPSocket1.Initialize("UDP", 5500, 1024)
    End If
    Dim Packet As UDPPacket
    Dim data() As Byte
    data = "Hello from Android".GetBytes("UTF8")
    Packet.Initialize(data, MYIPADRESS, 5500)
    UDPSocket1.Send(Packet)
End Sub

Sub UDP_PacketArrived (Packet As UDPPacket)
    Dim msg As String
    msg = BytesToString(Packet.Data, Packet.Offset, Packet.Length, "UTF8")
    Msgbox("Message received: " & msg, "")
End Sub
.... but when compiling I get an error....
B4X:
Compiling code                                   0.02
Generating R file                                 0.02
Compiling generated Java code              Error
javac 1.6.0_29
src\network\this\main.java:1: <identifier> expected
package network.this;
                        ^
1 error
 
Last edited:

PaulR

Active Member
Licensed User
Longtime User
Is that sample code compiling correctly for anyone? (replacing MYIPADDRESS obviously)
 
Upvote 0
Top