multiple Network connect & disconnect

konisek

Member
Licensed User
Longtime User
For connection I use:
B4X:
Sub connect_Click
   ErrorLabel(NoServer)
   client.New1
   client.Connect(IP,10001) 
   textBox3.Text = "Connected"
              ......
   Return True
NoServer:
   Return False
End Sub

and for disconnection I use:
B4X:
Sub disconnect_click
   ...
   client.Close 
   textBox3.Text = "no connection"
End Sub

When I connect and then disconnect, everything works fine. But when I try to connect again, it refuces the connection saying:
No connection could be made because the target machine actively refused it.

Does it mean that the disconnect_click works not?
It behaves like this only on PDA whereas on the PC I can connect/disconnect as many times as I want.
(L)
 

konisek

Member
Licensed User
Longtime User
Unfortunately, it did not help. I still get the same error. I cannot disconnect the client.
 

konisek

Member
Licensed User
Longtime User
The server side is not a desktop PC but a hardware ethernet/rs232 converter with its public IP address and port. Therefore I do not have any source code for the server. From PDA I connect to it via gprs or wifi.
The converter can be setup with its web interface but it does not enable much setting - see the attachm. When I shut down the application, the client, of course disconnects.
(L)
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
@Erel I thought you had modified the Network library to close the stream but it doesn't look like it as the Network.cs is version 1.0.
Probably missed this issue. Thanks.

Please download the attached library and copy both files to the libraries folder (c:\program files\Anywhere Software\Basic4ppc Desktop\Libraries)

When you compile your program, the message box should say Network.dll version 1.02.
 

Attachments

  • Network.zip
    3.1 KB · Views: 228

konisek

Member
Licensed User
Longtime User
OK, I will try. Another question of mine:
When I run the program and gprs (data) is not connected, I get the following error msg:
B4X:
A socket operation was attempted to an unreachable host.]
The reason is obvious.

I have to go to:
Start\Settings\Connections\My ISP\Manage existing connections\
and manually tap and hold (and connect) the Connection.
The gprs data then connect and I can run my program without any error.

So, my question is - How to make the program connect the data automatically?
(L)
 

konisek

Member
Licensed User
Longtime User
B4X:
Shell ("iexplore.exe","")
does not connect gprs

B4X:
response.New1
request.New1 (URL)
request.Method = "POST"
request.TimeOut = 60000
request.ContentType = "application/x-www-form-urlencoded"
does connect gprs

However it takes approx. 20 seconds to connect gprs.

If I use
Start\Settings\Connections\My ISP\Manage existing connections\
and manually tap and hold (and connect) the Connection

it takes only 7 seconds to connect gprs.
Is there a way to shorten those 20 seconds?
 
Last edited:

konisek

Member
Licensed User
Longtime User
Now, I do.
Running the script:
B4X:
38#:CMP -GPRS SW?\windows\cmpres.dll,-114
connets in 6 seconds/disconnects in 1 second :)
 
Top