winsock and a socket example

tmV23

Member
Licensed User
Longtime User
This is made to talk to vb6 winsock listening app.

It works good on the emulator.
Does not work on a real device.:sign0163:

I've tried most all of the obvious things i think. again it works good on the emulator.
The device is on a Local Wifi network trying to talk to a local PC running a vb6 app setup to listen and accept any requests to connect. The device has permission to be on the network. I've tried different ports I've tried different android devices. I've tried using the b4aBridge. Nothing works but the emulator.

Can I use LogCat to find out? LogCat shows no info other then Pause and Resume and Create. Nothing about Socket attempts.

B4X:
'Activity module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   Dim Socket1 As Socket 
   Dim ServerSocket1 As ServerSocket 
   Dim AStreams As AsyncStreams 
End Sub
Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.
   Dim btnConnect As Button
   Dim btnClose As Button
   Dim btnTest As Button
   Dim lvLog As ListView
   Dim lblMyIP As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("1")
   'Todo: Change typeface of lvLog
   lvLog.SingleLineLayout.ItemHeight = 16dip
   lvLog.SingleLineLayout.Label.TextSize = 12
   lblMyIP.Text = ServerSocket1.GetMyIP
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub btnTest_Click
   Dim Buffer() As Byte 
   msg = "Hello"   
   Buffer = msg.GetBytes("UTF8")
   Astreams.Write(Buffer)
   lvLog.AddSingleLine ("Sent " & msg)
End Sub
Sub btnConnect_Click
   Socket1.Initialize("Socket1")
   Socket1.Connect("192.168.10.110",81,5000)
   lvLog.AddSingleLine ("Do Connect")
End Sub
Sub btnClose_Click
   Socket1.Close
   lvLog.AddSingleLine ("Do Close")
End Sub
Sub Socket1_Connected(Connected As Boolean)As Boolean 
   If Connected = True Then
      AStreams.Initialize(Socket1.InputStream,Socket1.OutputStream,"Astreams")
      lvLog.AddSingleLine ("Is Connected")
   End If
End Sub
 

tmV23

Member
Licensed User
Longtime User
The solution is to allow the vb6 app running the winsock component permission in the windows Firewall under the Exceptions tab by clicking on Add Program.
 
Upvote 0

tmV23

Member
Licensed User
Longtime User
Answer to dclarkchem

dclarkchem:
Did you ever get a resolution to this problem?

I'm frustrated after a couple of weeks working with this program and not getting answers to what should be a simple problem!


Yes it works good.
 
Upvote 0

tmV23

Member
Licensed User
Longtime User
TestTcpIp

dclarkchem:
I have tweaked and played with the TestTcpIp program and a VB6 winsock program for hours (actually for several hours for 4 days).

I get this message "Server not available" hundreds of times, regardless of how I set the winsock program.

I turn off my firewall during each test, so that the firewall blocking is not an issue. I tinker with the port, the IP address, etc.

May I send you the VB program and you can have a look?
Alternately, would you send me the VB6 code that works with TestTcpIp?
Thanks in advance.


The VB app I used and does work is in this thread.
http://www.b4x.com/forum/search.php?searchid=830896
Good Luck ! double check all your numbers.
 
Upvote 0
Top