Made tcp_listen return the client IP address.

Together with the recent change to provide the inbound data buffer address and length to the TCP callback function as C parameters this change allows the TCP API to get along without any global variable :-)
This commit is contained in:
Oliver Schmidt 2017-11-08 20:59:06 +01:00
parent e1bf89d1a8
commit e6684904cf
2 changed files with 11 additions and 3 deletions

View File

@ -181,9 +181,9 @@ unsigned char __fastcall__ udp_send(const unsigned char* buf, unsigned int len,
// callback: Vector to call when data arrives on this connection
// buf: Pointer to buffer with data received
// len: -1 on close, otherwise length of data received
// Output: 1 if an error occured, 0 otherwise
// Output: IP address of the connected client, 0 on error
//
unsigned char __fastcall__ tcp_listen(unsigned int port,
unsigned long __fastcall__ tcp_listen(unsigned int port,
void (*callback)(const unsigned char* buf, int len));
// Make outbound TCP connection

View File

@ -15,6 +15,7 @@
.import tcp_send_keep_alive
.import tcp_callback
.import tcp_remote_ip
.import tcp_connect_ip
.import tcp_send_data_len
@ -40,9 +41,16 @@ _tcp_listen:
stax tcp_callback
jsr popax
jsr tcp_listen
bcs error
ldax tcp_remote_ip+2
stax sreg
ldax tcp_remote_ip
rts
error:
ldx #$00
txa
rol
stax sreg
rts
_tcp_connect: