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