std1.0.0-beta-7 SafeC docs

std :: net::tcp

Struct std::TcpConn

#include <std/net/tcp.h> source

struct TcpConn {
    int state;
    unsigned int local_ip;
    unsigned int remote_ip;
    unsigned short local_port;
    unsigned short remote_port;
    unsigned int snd_nxt;
    unsigned int snd_una;
    unsigned int rcv_nxt;
    unsigned int rcv_wnd;
    unsigned char rx_buf[TCP_RX_BUF];
    unsigned long rx_len;
    unsigned char tx_buf[TCP_TX_BUF];
    unsigned long tx_len;
}

Fields

§int statesource
§unsigned int local_ipsource
§unsigned int remote_ipsource
§unsigned short local_portsource
§unsigned short remote_portsource
§unsigned int snd_nxtsource

next sequence number to send

§unsigned int snd_unasource

oldest unacknowledged sequence number

§unsigned int rcv_nxtsource

next expected receive sequence number

§unsigned int rcv_wndsource

receive window advertised

§unsigned char rx_buf[TCP_RX_BUF]source
§unsigned long rx_lensource
§unsigned char tx_buf[TCP_TX_BUF]source
§unsigned long tx_lensource

Methods

§int recv(&PacketBuf pkt, unsigned long tcp_offset)source · definition

Feed a received packet (starting at TCP header offset in pkt). Returns 1 if state changed, 0 otherwise.

§unsigned long send([]const unsigned char data)source · definition

Enqueue payload data to send. Returns bytes accepted (0 if full).

§int build_segment( &PacketBuf pkt, const unsigned char eth_src[NET_MAC_LEN], const unsigned char eth_dst[NET_MAC_LEN], )source · definition

Build next outgoing segment into pkt; returns 1 if segment produced.

§int rx_ready() constsource · definition

Is there received data ready?

§unsigned long read([]unsigned char out)source · definition

Consume up to out.len bytes from rx_buf into out; returns bytes copied.

§void connect( unsigned int remote_ip, unsigned short remote_port, unsigned int local_ip, unsigned short local_port, unsigned int isn, )source · definition

Initiate active open (send SYN).

§void listen(unsigned int local_ip, unsigned short local_port, unsigned int isn)source · definition

Passive open: wait in LISTEN for a SYN to local_port. The peer's address/port are taken from that SYN; the next build_segment() then produces the SYN+ACK (with sequence number 'isn').

§void drop()source · definition

Close connection (send FIN).

§void close() consumesource · definition

= drop()