[mini] Add new JIT flag JIT_FLAG_DISCARD_RESULTS to reduce the noise when profiling...
[mono.git] / mono / io-layer / sockets.h
1 /*
2  * sockets.h:  Socket handles
3  *
4  * Author:
5  *      Dick Porter (dick@ximian.com)
6  *
7  * (C) 2002 Ximian, Inc.
8  */
9
10 #ifndef _WAPI_SOCKETS_H_
11 #define _WAPI_SOCKETS_H_
12
13 #include "mono/io-layer/wapi.h"
14
15 G_BEGIN_DECLS
16
17 #define WSADESCRIPTION_LEN 256
18 #define WSASYS_STATUS_LEN 128
19
20 typedef struct 
21 {
22         guint16 wVersion;
23         guint16 wHighVersion;
24         char szDescription[WSADESCRIPTION_LEN+1];
25         char szSystemStatus[WSASYS_STATUS_LEN+1];
26         guint16 iMaxSockets;
27         guint16 iMaxUdpDg;
28         guchar *lpVendorInfo;
29 } WapiWSAData;
30
31 #define INVALID_SOCKET (guint32)(~0)
32 #define SOCKET_ERROR -1
33
34 #define WSAID_DISCONNECTEX {0x7fda2e11,0x8630,0x436f,{0xa0, 0x31, 0xf5, 0x36, 0xa6, 0xee, 0xc1, 0x57}}
35 #define WSAID_TRANSMITFILE {0xb5367df0,0xcbac,0x11cf,{0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92}}
36
37 typedef struct
38 {
39         guint32 Data1;
40         guint16 Data2;
41         guint16 Data3;
42         guint8 Data4[8];
43 } WapiGuid;
44
45 typedef struct
46 {
47         gpointer Head;
48         guint32 HeadLength;
49         gpointer Tail;
50         guint32 TailLength;
51 } WapiTransmitFileBuffers;
52
53 typedef enum {
54         TF_USE_DEFAULT_WORKER   = 0,
55         TF_DISCONNECT           = 0x01,
56         TF_REUSE_SOCKET         = 0x02,
57         TF_WRITE_BEHIND         = 0x04,
58         TF_USE_SYSTEM_THREAD    = 0x10,
59         TF_USE_KERNEL_APC       = 0x20
60 } WapiTransmitFileFlags;
61
62 typedef struct
63 {
64         guint32 len;
65         gpointer buf;
66 } WapiWSABuf;
67
68 /* If we need to support more WSAIoctl commands then define these
69  * using the bitfield flags method
70  */
71 #define SIO_GET_EXTENSION_FUNCTION_POINTER 0xC8000006
72 #define SIO_KEEPALIVE_VALS 0x98000004
73
74 typedef gboolean (*WapiDisconnectExFn)(guint32, WapiOverlapped *, guint32,
75                                         guint32);
76 typedef gboolean (*WapiTransmitFileFn)(guint32, gpointer, guint32, guint32,
77                                         WapiOverlapped *,
78                                         WapiTransmitFileBuffers *,
79                                         WapiTransmitFileFlags);
80
81 extern void WSASetLastError(int error);
82 extern int WSAGetLastError(void);
83 extern int closesocket(guint32 handle);
84
85 extern int ioctlsocket(guint32 handle, unsigned long command, gpointer arg);
86 extern int WSAIoctl (guint32 handle, gint32 command,
87                      gchar *input, gint i_len,
88                      gchar *output, gint o_len, glong *written,
89                      void *unused1, void *unused2);
90 extern int WSARecv (guint32 handle, WapiWSABuf *buffers, guint32 count,
91                     guint32 *received, guint32 *flags,
92                     WapiOverlapped *overlapped, WapiOverlappedCB *complete);
93 extern int WSASend (guint32 handle, WapiWSABuf *buffers, guint32 count,
94                     guint32 *sent, guint32 flags,
95                     WapiOverlapped *overlapped, WapiOverlappedCB *complete);
96
97 gboolean TransmitFile (guint32 socket, gpointer file, guint32 bytes_to_write, guint32 bytes_per_send, WapiOverlapped *ol,
98                         WapiTransmitFileBuffers *tb, guint32 flags);
99 G_END_DECLS
100 #endif /* _WAPI_SOCKETS_H_ */