Ahem. The log-file Browse button should set cfg.logfilename and not
[sgt/putty] / network.h
CommitLineData
2f75bae1 1/*
2 * Networking abstraction in PuTTY.
3 *
4 * The way this works is: a back end can choose to open any number
5 * of sockets - including zero, which might be necessary in some.
6 * It can register a function to be called when data comes in on
7 * any given one, and it can call the networking abstraction to
8 * send data without having to worry about blocking. The stuff
9 * behind the abstraction takes care of selects and nonblocking
10 * writes and all that sort of painful gubbins.
11 *
12 * If urgent data comes in on a socket, the back end will read and
13 * discard up to the urgent pointer, then read the urgent byte and
14 * send _that_ to the receiver function with `urgent' set.
15 */
16
49bad831 17#ifndef PUTTY_NETWORK_H
18#define PUTTY_NETWORK_H
19
2f75bae1 20typedef struct Socket_tag *Socket;
21typedef struct SockAddr_tag *SockAddr;
22typedef int (*sk_receiver_t)(Socket s, int urgent, char *data, int len);
23
24void sk_init(void); /* called once at program startup */
25
26SockAddr sk_namelookup(char *host, char **canonicalname);
27void sk_addr_free(SockAddr addr);
28
c91409da 29Socket sk_new(SockAddr addr, int port, int privport, sk_receiver_t receiver);
2f75bae1 30void sk_close(Socket s);
31void sk_write(Socket s, char *buf, int len);
32void sk_write_oob(Socket s, char *buf, int len);
33
34/*
35 * Each socket abstraction contains a `void *' private field in
36 * which the client can keep state.
37 */
38void sk_set_private_ptr(Socket s, void *ptr);
39void *sk_get_private_ptr(Socket s);
40
41/*
42 * Special error values are returned from sk_namelookup and sk_new
43 * if there's a problem. These functions extract an error message,
44 * or return NULL if there's no problem.
45 */
46char *sk_addr_error(SockAddr addr);
47char *sk_socket_error(Socket addr);
49bad831 48
49#endif