yong-stropheruby 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/ext/sock.h ADDED
@@ -0,0 +1,51 @@
1
+ /* sock.h
2
+ ** strophe XMPP client library -- socket abstraction header
3
+ **
4
+ ** Copyright (C) 2005-2008 OGG, LLC. All rights reserved.
5
+ **
6
+ ** This software is provided AS-IS with no warranty, either express
7
+ ** or implied.
8
+ **
9
+ ** This software is distributed under license and may not be copied,
10
+ ** modified or distributed except as expressly authorized under the
11
+ ** terms of the license contained in the file LICENSE.txt in this
12
+ ** distribution.
13
+ */
14
+
15
+ /** @file
16
+ * Socket abstraction API.
17
+ */
18
+
19
+ #ifndef __LIBSTROPHE_SOCK_H__
20
+ #define __LIBSTROPHE_SOCK_H__
21
+
22
+ #include <stdio.h>
23
+
24
+ #ifndef _WIN32
25
+ typedef int sock_t;
26
+ #else
27
+ #include <winsock2.h>
28
+ typedef SOCKET sock_t;
29
+ #endif
30
+
31
+ void sock_initialize(void);
32
+ void sock_shutdown(void);
33
+
34
+ int sock_error(void);
35
+
36
+ sock_t sock_connect(const char * const host, const unsigned int port);
37
+ int sock_close(const sock_t sock);
38
+
39
+ int sock_set_blocking(const sock_t sock);
40
+ int sock_set_nonblocking(const sock_t sock);
41
+ int sock_read(const sock_t sock, void * const buff, const size_t len);
42
+ int sock_write(const sock_t sock, const void * const buff, const size_t len);
43
+ int sock_is_recoverable(const int error);
44
+ /* checks for an error after connect, return 0 if connect successful */
45
+ int sock_connect_error(const sock_t sock);
46
+
47
+ int sock_srv_lookup(const char *service, const char *proto,
48
+ const char *domain, char *resulttarget,
49
+ int resulttargetlength, int *resultport);
50
+
51
+ #endif /* __LIBSTROPHE_SOCK_H__ */