Subversion Repositories Kolibri OS

Rev

Rev 5499 | Rev 5676 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5499 Rev 5598
-
 
1
#ifndef INCLUDE_SOCKET_H
-
 
2
#define INCLUDE_SOCKET_H
-
 
3
 
-
 
4
#ifndef INCLUDE_KOLIBRI_H
-
 
5
#include "../lib/kolibri.h"
-
 
6
#endif
-
 
7
 
1
#define SOCK_STREAM 1
8
#define SOCK_STREAM 1
2
#define	SOCK_DGRAM 2
9
#define	SOCK_DGRAM 2
3
 
10
 
4
#define AF_INET4 2 
11
#define AF_INET4 2 
5
 
12
 
6
#define MSG_PEEK 0x02
13
#define MSG_PEEK 0x02
7
#define MSG_DONTWAIT 0x40
14
#define MSG_DONTWAIT 0x40
8
 
15
 
9
dword errorcode;
16
dword errorcode;
10
 
17
 
-
 
18
struct 	sockaddr_in
11
struct 	sockaddr_in{
19
{
12
        word    sin_family; 
20
        word    sin_family; 
13
        word    sin_port; 
21
        word    sin_port; 
14
        dword   sin_addr;
22
        dword   sin_addr;
15
        char    padding[8];
23
        char    padding[8];
16
};  
24
};  
17
 
25
 
18
inline fastcall dword Socket(ECX, EDX, ESI)
26
inline fastcall dword Socket(ECX, EDX, ESI)
19
{
27
{
20
	$push	ebx
28
	$push	ebx
21
	$mov 	eax, 75
29
	$mov 	eax, 75
22
	$mov 	ebx, 0
30
	$mov 	ebx, 0
23
	$int 	0x40
31
	$int 	0x40
24
	errorcode = EBX;
32
	errorcode = EBX;
25
	$pop	ebx
33
	$pop	ebx
26
} 
34
} 
27
 
35
 
28
inline fastcall dword Close(ECX)
36
inline fastcall dword Close(ECX)
29
{
37
{
30
	$push	ebx
38
	$push	ebx
31
	$mov 	eax, 75
39
	$mov 	eax, 75
32
	$mov 	ebx, 1
40
	$mov 	ebx, 1
33
	$int 	0x40
41
	$int 	0x40
34
	errorcode = EBX;
42
	errorcode = EBX;
35
	$pop	ebx	
43
	$pop	ebx	
36
}
44
}
37
 
45
 
38
inline fastcall dword Bind(ECX, EDX, ESI)
46
inline fastcall dword Bind(ECX, EDX, ESI)
39
{
47
{
40
	$push	ebx
48
	$push	ebx
41
	$mov 	eax, 75
49
	$mov 	eax, 75
42
	$mov 	ebx, 2
50
	$mov 	ebx, 2
43
	$int 	0x40
51
	$int 	0x40
44
	errorcode = EBX;
52
	errorcode = EBX;
45
	$pop	ebx
53
	$pop	ebx
46
}
54
}
47
 
55
 
48
inline fastcall dword Listen(ECX, EDX)
56
inline fastcall dword Listen(ECX, EDX)
49
{
57
{
50
	$push	ebx
58
	$push	ebx
51
	$mov 	eax, 75
59
	$mov 	eax, 75
52
	$mov 	ebx, 3
60
	$mov 	ebx, 3
53
	$int 	0x40
61
	$int 	0x40
54
	errorcode = EBX;
62
	errorcode = EBX;
55
	$pop	ebx
63
	$pop	ebx
56
}
64
}
57
 
65
 
58
inline fastcall dword Connect(ECX, EDX, ESI)
66
inline fastcall dword Connect(ECX, EDX, ESI)
59
{
67
{
60
	$push	ebx
68
	$push	ebx
61
	$mov 	eax, 75
69
	$mov 	eax, 75
62
	$mov 	ebx, 4
70
	$mov 	ebx, 4
63
	$int 	0x40
71
	$int 	0x40
64
	errorcode = EBX;
72
	errorcode = EBX;
65
	$pop	ebx
73
	$pop	ebx
66
}
74
}
67
 
75
 
68
inline fastcall dword Accept(ECX, EDX, ESI)
76
inline fastcall dword Accept(ECX, EDX, ESI)
69
{
77
{
70
	$push	ebx
78
	$push	ebx
71
	$mov 	eax, 75
79
	$mov 	eax, 75
72
	$mov 	ebx, 5
80
	$mov 	ebx, 5
73
	$int 	0x40
81
	$int 	0x40
74
	errorcode = EBX;
82
	errorcode = EBX;
75
	$pop	ebx
83
	$pop	ebx
76
}
84
}
77
 
85
 
78
inline fastcall dword Send(ECX, EDX, ESI, EDI)
86
inline fastcall dword Send(ECX, EDX, ESI, EDI)
79
{
87
{
80
	$push	ebx
88
	$push	ebx
81
	$mov 	eax, 75
89
	$mov 	eax, 75
82
	$mov 	ebx, 6
90
	$mov 	ebx, 6
83
	$int 	0x40
91
	$int 	0x40
84
	errorcode = EBX;
92
	errorcode = EBX;
85
	$pop	ebx
93
	$pop	ebx
86
}
94
}
87
 
95
 
88
inline fastcall dword Receive(ECX, EDX, ESI, EDI)
96
inline fastcall dword Receive(ECX, EDX, ESI, EDI)
89
{
97
{
90
	$push	ebx
98
	$push	ebx
91
	$mov 	eax, 75
99
	$mov 	eax, 75
92
	$mov 	ebx, 7
100
	$mov 	ebx, 7
93
	$int 	0x40
101
	$int 	0x40
94
	errorcode = EBX;
102
	errorcode = EBX;
95
	$pop	ebx
103
	$pop	ebx
96
}
104
}
-
 
105
 
-
 
106
#endif
97
107