equal
deleted
inserted
replaced
9 #include <err.h> |
9 #include <err.h> |
10 |
10 |
11 #include "sock.h" |
11 #include "sock.h" |
12 |
12 |
13 #define CONNECT_HOST "irc.fixme.fi" |
13 #define CONNECT_HOST "irc.fixme.fi" |
14 #define CONNECT_SERV "6667" |
14 #define CONNECT_SERV "6697" |
15 #define LINE_LENGTH 512 |
15 #define LINE_LENGTH 512 |
16 |
16 |
17 struct recvline_state { |
17 struct recvline_state { |
18 size_t tail_offset; |
18 size_t tail_offset; |
19 size_t tail_len; |
19 size_t tail_len; |
108 struct sock_stream *sock; |
108 struct sock_stream *sock; |
109 char line_buf[LINE_LENGTH + 1]; |
109 char line_buf[LINE_LENGTH + 1]; |
110 struct recvline_state recvline_ctx; |
110 struct recvline_state recvline_ctx; |
111 |
111 |
112 // initialize |
112 // initialize |
|
113 sock_init(); |
113 memset(&recvline_ctx, 0, sizeof(recvline_ctx)); |
114 memset(&recvline_ctx, 0, sizeof(recvline_ctx)); |
114 |
115 |
115 // over-simplified connect |
116 // over-simplified connect |
116 sock = sock_tcp_connect(CONNECT_HOST, CONNECT_SERV); |
117 sock = sock_ssl_connect(CONNECT_HOST, CONNECT_SERV); |
117 |
118 |
118 // read lines and dump them out |
119 // read lines and dump them out |
119 do { |
120 do { |
120 // recv |
121 // recv |
121 recvline(sock, line_buf, sizeof(line_buf), &recvline_ctx); |
122 recvline(sock, line_buf, sizeof(line_buf), &recvline_ctx); |