]>
Commit | Line | Data |
---|---|---|
904ec517 GRG |
1 | /* ------------------------------------------------------------------------- |
2 | * Project: GSocket (Generic Socket) for WX | |
3 | * Name: gsockmsw.h | |
4 | * Purpose: GSocket MSW header | |
5 | * CVSID: $Id$ | |
6 | * ------------------------------------------------------------------------- | |
7 | */ | |
8 | ||
9 | #ifndef __GSOCK_MSW_H | |
10 | #define __GSOCK_MSW_H | |
11 | ||
0ce742cf GRG |
12 | #ifndef __GSOCKET_STANDALONE__ |
13 | #include "wx/setup.h" | |
14 | #endif | |
15 | ||
16 | #if wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) | |
17 | ||
c21b68f7 | 18 | #ifndef __GSOCKET_STANDALONE__ |
904ec517 GRG |
19 | #include "wx/gsocket.h" |
20 | #else | |
21 | #include "gsocket.h" | |
22 | #endif | |
23 | ||
c09f2879 | 24 | #include <windows.h> |
904ec517 GRG |
25 | #include <winsock.h> |
26 | ||
c21b68f7 GRG |
27 | #ifdef __cplusplus |
28 | extern "C" { | |
29 | #endif | |
30 | ||
5c9eff30 GRG |
31 | #if !defined(__cplusplus) |
32 | typedef int bool; | |
33 | #endif | |
34 | ||
35 | #ifndef TRUE | |
36 | #define TRUE 1 | |
37 | #endif | |
38 | ||
39 | #ifndef FALSE | |
40 | #define FALSE 0 | |
41 | #endif | |
42 | ||
904ec517 GRG |
43 | /* Definition of GSocket */ |
44 | struct _GSocket | |
45 | { | |
46 | SOCKET m_fd; | |
47 | GAddress *m_local; | |
48 | GAddress *m_peer; | |
49 | GSocketError m_error; | |
50 | ||
483249fc | 51 | /* Attributes */ |
904ec517 GRG |
52 | bool m_non_blocking; |
53 | bool m_server; | |
54 | bool m_stream; | |
55 | bool m_oriented; | |
2288191b | 56 | bool m_establishing; |
904ec517 GRG |
57 | struct timeval m_timeout; |
58 | ||
59 | /* Callbacks */ | |
483249fc | 60 | GSocketEventFlags m_detected; |
904ec517 GRG |
61 | GSocketCallback m_cbacks[GSOCK_MAX_EVENT]; |
62 | char *m_data[GSOCK_MAX_EVENT]; | |
63 | int m_msgnumber; | |
64 | }; | |
65 | ||
66 | /* Definition of GAddress */ | |
67 | struct _GAddress | |
68 | { | |
69 | struct sockaddr *m_addr; | |
70 | size_t m_len; | |
71 | ||
72 | GAddressType m_family; | |
73 | int m_realfamily; | |
74 | ||
75 | GSocketError m_error; | |
76 | }; | |
77 | ||
904ec517 GRG |
78 | /* Input / output */ |
79 | ||
80 | GSocketError _GSocket_Input_Timeout(GSocket *socket); | |
81 | GSocketError _GSocket_Output_Timeout(GSocket *socket); | |
d3ea6527 | 82 | GSocketError _GSocket_Connect_Timeout(GSocket *socket); |
904ec517 GRG |
83 | int _GSocket_Recv_Stream(GSocket *socket, char *buffer, int size); |
84 | int _GSocket_Recv_Dgram(GSocket *socket, char *buffer, int size); | |
85 | int _GSocket_Send_Stream(GSocket *socket, const char *buffer, int size); | |
86 | int _GSocket_Send_Dgram(GSocket *socket, const char *buffer, int size); | |
87 | ||
88 | /* Callbacks */ | |
89 | ||
70988afb GRG |
90 | bool _GSocket_GUI_Init(GSocket *socket); |
91 | void _GSocket_GUI_Destroy(GSocket *socket); | |
92 | ||
93 | LRESULT CALLBACK _GSocket_Internal_WinProc(HWND, UINT, WPARAM, LPARAM); | |
94 | ||
483249fc GRG |
95 | void _GSocket_Enable_Events(GSocket *socket); |
96 | void _GSocket_Disable_Events(GSocket *socket); | |
904ec517 GRG |
97 | |
98 | /* GAddress */ | |
99 | ||
100 | GSocketError _GAddress_translate_from(GAddress *address, | |
101 | struct sockaddr *addr, int len); | |
d3ea6527 GRG |
102 | GSocketError _GAddress_translate_to (GAddress *address, |
103 | struct sockaddr **addr, int *len); | |
904ec517 GRG |
104 | GSocketError _GAddress_Init_INET(GAddress *address); |
105 | GSocketError _GAddress_Init_UNIX(GAddress *address); | |
106 | ||
107 | #ifdef __cplusplus | |
108 | } | |
109 | #endif | |
110 | ||
0ce742cf GRG |
111 | #endif /* wxUSE_SOCKETS || defined(__GSOCKET_STANDALONE__) */ |
112 | ||
904ec517 | 113 | #endif /* __GSOCK_MSW_H */ |