net: ipv4 packet builder and interpreter, minor improvements in net system
[quarnos.git] / resources / net / tcp_client_socket.h
blobd85b468a5d0d413105e3604e3cdb0f37ca2921f8
1 #ifndef _TCP_CLIENT_SOCKET_H_
2 #define _TCP_CLIENT_SOCKET_H_
4 #include "tcp.h"
5 #include "client_socket.h"
6 #include "libs/fifo.h"
8 namespace net {
9 class tcp_client_socket : public client_socket {
10 private:
11 p<tcp> down_tcp;
13 int client_port;
15 int server_port;
16 ipv4_addr server;
18 fifo<buffer> incoming_data;
20 int sequence_number;
21 int ack_number;
23 enum connection_state {
24 unknown,
25 //listen,
26 syn_sent,
27 //syn_recv,
28 established,
29 fin_wait1,
30 fin_wait2,
31 //time_wait,
32 //close_wait,
33 last_ack,
34 closed
37 volatile connection_state state;
39 void receive(const ipv4_addr &addr, u16 sender_port, const buffer &data, tcp::tcp_flags, int, int);
40 void clean();
41 public:
42 tcp_client_socket(p<transport_layer> tl);
43 ~tcp_client_socket();
45 void connect(const ipv4_addr &addr, int port);
47 void write(const buffer &data);
48 void read(buffer &data);
50 void close();
54 #endif