Subversion Repositories Kolibri OS

Rev

Rev 5676 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
5598 pavelyakov 1
#ifndef INCLUDE_SOCKET_H
2
#define INCLUDE_SOCKET_H
5676 pavelyakov 3
#print "[include ]\n"
5598 pavelyakov 4
 
5
#ifndef INCLUDE_KOLIBRI_H
6
#include "../lib/kolibri.h"
7
#endif
8
 
9
#define SOCK_STREAM 1
10
#define	SOCK_DGRAM 2
11
 
9287 leency 12
#define AF_INET4 2
5598 pavelyakov 13
 
14
#define MSG_PEEK 0x02
15
#define MSG_DONTWAIT 0x40
16
 
9287 leency 17
struct 	SockAddr
5598 pavelyakov 18
{
9287 leency 19
  word    sin_family;
20
  char    data[14];
21
};
5598 pavelyakov 22
 
9287 leency 23
// ecx = domain
24
// edx = type
25
// esi = protocol
26
inline fastcall dword socket_open(ECX, EDX, ESI)
5598 pavelyakov 27
{
28
	$mov 	eax, 75
9287 leency 29
	$mov 	bl, 0
5598 pavelyakov 30
	$int 	0x40
9287 leency 31
}
5598 pavelyakov 32
 
9287 leency 33
// ecx = socket number
34
inline fastcall dword socket_close(ECX)
5598 pavelyakov 35
{
36
	$mov 	eax, 75
9287 leency 37
	$mov 	bl, 1
5598 pavelyakov 38
	$int 	0x40
39
}
40
 
9287 leency 41
// ecx = socket number
42
// edx = pointer to sockaddr structure
43
// esi = length of sockaddr structure
44
inline fastcall dword socket_bind(ECX, EDX, ESI)
5598 pavelyakov 45
{
46
	$mov 	eax, 75
9287 leency 47
	$mov 	bl, 2
5598 pavelyakov 48
	$int 	0x40
49
}
50
 
9287 leency 51
// ecx = socket number
52
// edx = backlog
53
inline fastcall dword socket_listen(ECX, EDX)
5598 pavelyakov 54
{
55
	$mov 	eax, 75
9287 leency 56
	$mov 	bl, 3
5598 pavelyakov 57
	$int 	0x40
58
}
59
 
9287 leency 60
// ecx = socket number
61
// edx = pointer to sockaddr structure
62
// esi = length of sockaddr structure
63
inline fastcall dword socket_connect(ECX, EDX, ESI)
5598 pavelyakov 64
{
65
	$mov 	eax, 75
9287 leency 66
	$mov 	bl, 4
5598 pavelyakov 67
	$int 	0x40
68
}
69
 
9287 leency 70
// ecx = socket number
71
// edx = pointer to sockaddr structure
72
// esi = length of sockaddr structure
73
inline fastcall dword socket_accept(ECX, EDX, ESI)
5598 pavelyakov 74
{
75
	$mov 	eax, 75
9287 leency 76
	$mov 	bl, 5
5598 pavelyakov 77
	$int 	0x40
78
}
79
 
9287 leency 80
// ecx = socket number
81
// edx = pointer to buffer
82
// esi = length of buffer
83
// edi = flags
84
inline fastcall dword socket_send(ECX, EDX, ESI, EDI)
5598 pavelyakov 85
{
86
	$mov 	eax, 75
9287 leency 87
	$mov 	bl, 6
5598 pavelyakov 88
	$int 	0x40
89
}
90
 
9287 leency 91
// ecx = socket number
92
// edx = pointer to buffer
93
// esi = length of buffer
94
// edi = flags
95
inline fastcall dword socket_receive(ECX, EDX, ESI, EDI)
5598 pavelyakov 96
{
97
	$mov 	eax, 75
9287 leency 98
	$mov 	bl, 7
5598 pavelyakov 99
	$int 	0x40
100
}
101
 
102
#endif