B4J Question FTP server port 21

ajk

Active Member
Licensed User
Longtime User
Using this code
B4X:
Sub Process_Globals
    Private server As FTPServer
End Sub

Sub AppStart (Args() As String)
    server.Initialize(Me, "FTPServer")
    server.SetPorts(99, 51045, 51057)
    server.AddUser("dddd", "dddd")
    server.Start
    StartMessageLoop
End Sub

Sub FTPServer_StateChanged
    Log($"Number of clients: ${server.NumberOfClients}"$)
End Sub

I can establish working connection. Change port number to 21 - like:

B4X:
server.SetPorts(21, 51045, 51057)

gives error

B4X:
Number of clients: 0
terminated
Number of clients: 1
User logged in: dddd
CurrentPath: F:/PROG_19/ _____B4J/FTP serwer
java.net.SocketException: Software caused connection abort: socket write error
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:111)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:143)
    at anywheresoftware.b4a.randomaccessfile.AsyncStreams$AOUT.run(AsyncStreams.java:355)
    at java.lang.Thread.run(Thread.java:748)
java.net.SocketException: Software caused connection abort: recv failed
    at java.net.SocketInputStream.socketRead0(Native Method)
    at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
    at java.net.SocketInputStream.read(SocketInputStream.java:171)
    at java.net.SocketInputStream.read(SocketInputStream.java:141)
    at java.net.SocketInputStream.read(SocketInputStream.java:127)
    at anywheresoftware.b4a.randomaccessfile.AsyncStreams$AIN.run(AsyncStreams.java:216)
    at java.lang.Thread.run(Thread.java:748)
error: (SocketException) java.net.SocketException: Software caused connection abort: recv failed
error: (SocketException) java.net.SocketException: Software caused connection abort: recv failed
terminated
Number of clients: 0
terminated

Settng 21 or 22 in SetPorts trigger this. DataPortBegin and DataPortEnd seems to be irrelevant.
Tested on all versions of FTP server and several distributions of java on Mac and Windows.
 
Top