-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c646552
commit b668c1e
Showing
4 changed files
with
706 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
layout: post | ||
title: "LwIP TCP API" | ||
date: 2023-10-09 00:00:00 -0400 | ||
--- | ||
|
||
# Minimal LwIP TCP API (as used on a Raspberry PI pico-w) | ||
|
||
### tcp_new() | ||
``` | ||
struct tcp_pcb* tcp_new ( void ) | ||
struct tcp_pcb* tcp_new_ip_type ( u8_t type ) | ||
``` | ||
Creates a new TCP protocol control block but doesn't place it on any of the TCP PCB lists until binding using tcp_bind(). | ||
|
||
Parameters | ||
- IPADDR_TYPE_ANY| | ||
Returns | ||
- a new tcp_pcb that initially is in state CLOSED | ||
|
||
### tcp_bind() | ||
|
||
### tcp_connect() | ||
``` | ||
err_t tcp_connect ( struct tcp_pcb * pcb, const ip_addr_t * ipaddr, u16_t port, tcp_connected_fn connected) | ||
``` | ||
Parameters | ||
- pcb the tcp_pcb used to establish the connection | ||
- ipaddr the remote ip address to connect to | ||
- port the remote tcp port to connect to | ||
- connected callback function to call when connected (on error, the err calback will be called) | ||
Returns | ||
- ERR_VAL if invalid arguments are given ERR_OK if connect request has been sent other err_t values if connect request couldn't be sent | ||
|
||
### tcp_write() | ||
``` | ||
err_t tcp_write ( struct tcp_pcb * pcb, const void * arg, u16_t len, u8_t apiflags) | ||
``` | ||
Parameters | ||
- pcb Protocol control block for the TCP connection to enqueue data for. | ||
- arg Pointer to the data to be enqueued for sending. | ||
- len Data length in bytes | ||
- apiflags combination of following flags : | ||
- TCP_WRITE_FLAG_COPY (0x01) data will be copied into memory belonging to the stack | ||
- TCP_WRITE_FLAG_MORE (0x02) for TCP connection, PSH flag will not be set on last segment sent, | ||
Returns | ||
- ERR_OK if enqueued, another err_t on error | ||
|
||
### tcp_output() | ||
``` | ||
err_t tcp_output ( struct tcp_pcb * pcb ) | ||
``` | ||
Parameters | ||
- pcb Protocol control block for the TCP connection to send data | ||
Returns | ||
- ERR_OK if data has been sent or nothing to send another err_t on error | ||
|
||
|
Oops, something went wrong.