support abort in administra network code, re-init connections in websrv

This commit is contained in:
Joerg Deckert 2014-07-15 19:35:38 +02:00
parent 86f42864ec
commit 7b7e5bde66
2 changed files with 25 additions and 24 deletions

View File

@ -2493,7 +2493,7 @@ PRI lan_txflush | handleidx
handleidx := bus_getchar
sock.flush(sockhandle[handleidx])
\sock.flush(sockhandle[handleidx])
bus_putchar(TRUE)
@ -2554,7 +2554,7 @@ PRI lan_start | hiveid, hivestr, strpos, macpos, i, a
byte[hivestr+strpos] := 0
macpos--
sock.start(A_NETCS,A_NETSCK,A_NETSI,A_NETSO, -1, @mac_addr, @ip_addr)
\sock.start(A_NETCS,A_NETSCK,A_NETSI,A_NETSO, -1, @mac_addr, @ip_addr)
lan_started := true
@ -2566,7 +2566,7 @@ PRI lan_stop
''busprotokoll : [072]
if lan_started
sock.stop
\sock.stop
lan_started := false
PRI lan_connect | ipaddr, remoteport, handle, handleidx, i
@ -2589,8 +2589,8 @@ PRI lan_connect | ipaddr, remoteport, handle, handleidx, i
quit
i++
ifnot (handle := sock.connect(ipaddr, remoteport, @bufmain[i*rxlen], rxlen, @buftx[i*txlen], txlen)) == -102
sock.resetBuffers(handle)
ifnot (handle := \sock.connect(ipaddr, remoteport, @bufmain[i*rxlen], rxlen, @buftx[i*txlen], txlen)) == -102
\sock.resetBuffers(handle)
handleidx := handle.byte[0] 'extract the handle index from the lower 8 bits
sockhandle[handleidx] := handle 'komplettes handle zu handle index speichern
bufidx[i] :=handleidx
@ -2613,7 +2613,7 @@ PRI lan_listen | port, handle, handleidx, i
port := sub_getword
if handleidx <> $FF 'bestehender (kein neuer) Socket
if sock.isValidHandle(sockhandle[handleidx]) 'Socket gültig
if \sock.isValidHandle(sockhandle[handleidx]) 'Socket gültig
bus_putchar(handleidx) 'alten handleidx zurücksenden
return
@ -2630,7 +2630,7 @@ PRI lan_listen | port, handle, handleidx, i
quit
i++
ifnot (handle := sock.listen(port, @bufmain[i*rxlen], rxlen, @buftx[i*txlen], txlen)) == -102
ifnot (handle := \sock.listen(port, @bufmain[i*rxlen], rxlen, @buftx[i*txlen], txlen)) == -102
handleidx := handle.byte[0] 'extract the handle index from the lower 8 bits
sockhandle[handleidx] := handle 'komplettes handle zu handle index speichern
bufidx[i] :=handleidx
@ -2652,7 +2652,7 @@ PRI lan_waitconntimeout | handleidx, timeout, t, connected
timeout := sub_getword
t := cnt
repeat until (connected := sock.isConnected(sockhandle[handleidx])) or (((cnt - t) / (clkfreq / 1000)) > timeout)
repeat until (connected := \sock.isConnected(sockhandle[handleidx])) or (((cnt - t) / (clkfreq / 1000)) > timeout)
bus_putchar(connected)
@ -2666,7 +2666,7 @@ PRI lan_close | handleidx, i
handleidx := bus_getchar
sock.close(sockhandle[handleidx])
\sock.close(sockhandle[handleidx])
'reservierten Pufferabschnitt freigeben
i := 0
@ -2693,7 +2693,7 @@ PRI lan_rxtime | handleidx, timeout, t, rxbyte
timeout := sub_getword
t := cnt
repeat until (rxbyte := sock.readByteNonBlocking(sockhandle[handleidx])) => 0 or (not sock.isConnected(sockhandle[handleidx])) or (cnt - t) / (clkfreq / 1000) > timeout
repeat until (rxbyte := \sock.readByteNonBlocking(sockhandle[handleidx])) => 0 or (not \sock.isConnected(sockhandle[handleidx])) or (cnt - t) / (clkfreq / 1000) > timeout
bus_putchar(rxbyte)
@ -2713,8 +2713,8 @@ PRI lan_rxdata | handleidx, len, rxbyte, error
repeat len
ifnot error
repeat while (rxbyte := sock.readByteNonBlocking(sockhandle[handleidx])) < 0
ifnot sock.isConnected(sockhandle[handleidx])
repeat while (rxbyte := \sock.readByteNonBlocking(sockhandle[handleidx])) < 0
ifnot \sock.isConnected(sockhandle[handleidx])
error := sock#ERRSOCKETCLOSED
quit
bus_putchar(rxbyte)
@ -2738,8 +2738,8 @@ PRI lan_txdata | handleidx, len, txbyte, error
repeat len
txbyte := bus_getchar
ifnot error
repeat while sock.writeByteNonBlocking(sockhandle[handleidx], txbyte) < 0
ifnot sock.isConnected(sockhandle[handleidx])
repeat while \sock.writeByteNonBlocking(sockhandle[handleidx], txbyte) < 0
ifnot \sock.isConnected(sockhandle[handleidx])
error := sock#ERRSOCKETCLOSED
quit
@ -2756,7 +2756,7 @@ PRI lan_rxbyte
'' : rxbyte - empfangenes Zeichen oder
'' : sock#RETBUFFEREMPTY (-1) wenn kein Zeichen vorhanden
bus_putchar(sock.readByteNonBlocking(sockhandle[bus_getchar]))
bus_putchar(\sock.readByteNonBlocking(sockhandle[bus_getchar]))
PRI lan_isconnected
''funktionsgruppe : lan
@ -2767,7 +2767,7 @@ PRI lan_isconnected
'' : handleidx - lfd. Nr. der Verbindung
'' : connected - TRUE wenn verbunden, sonst FALSE
bus_putchar(sock.isConnected(sockhandle[bus_getchar]))
bus_putchar(\sock.isConnected(sockhandle[bus_getchar]))
DAT
long ' long alignment for addresses

View File

@ -64,7 +64,7 @@ VAR
long cog, random_value
PUB main
PUB main | i
rr_start
@ -85,16 +85,19 @@ PUB main
getcfg
ios.print(@strMsgEnd)
i := 0
repeat
if ios.keystat > 0
quit
if (handleidx := ios.lan_listen(handleidx,80)) == $FF 'Empfangs-Socket auf Port 80 öffnen
ios.print(@strErrorNoSock)
quit
if i > 20
ios.print(@strErrorNoSock)
quit
else
i++
next
i := 0
if ios.lan_isconnected(handleidx) 'bei bestehender Verbindung...
#ifdef __DEBUG
ios.print(@strConnected)
#endif
if webThread == 0
ios.lan_txflush(handleidx)
ios.lan_close(handleidx)
@ -224,7 +227,6 @@ DAT ' Locale
strNoNetwork byte 13,"Administra doesn't provide network functions!",13,"Please load admnet.",13,0
strWaitConnection byte "Waiting for client connection...",13,0
strConnected byte "Client connected...",13,0
strErrorNoSock byte "No free socket.",13,0
strErrorOpen byte "Can't open configuration file",13,0
strAddr byte 13,"Webserver startet, please use this URL to connect:",13," http://",0
@ -238,7 +240,6 @@ DAT ' Locale
strNoNetwork byte 13,"Administra stellt keine Netzwerk-Funktionen zur Verfügung!",13,"Bitte admnet laden.",13,0
strWaitConnection byte "Warte auf Client-Verbindung...",13,0
strConnected byte "Client verbunden...",13,0
strErrorNoSock byte "Kein Socket frei...",13,0
strErrorOpen byte "Kann Konfigurationsdatei nicht öffnen.",13,0
strAddr byte 13,"Webserver gestartet, zum Verbinden folgende URL verwenden:",13," http://",0