Subversion Repositories Kolibri OS

Rev

Rev 5676 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5676 Rev 9287
Line 12... Line 12...
12
#define AF_INET4 2 
12
#define AF_INET4 2
Line 13... Line 13...
13
 
13
 
14
#define MSG_PEEK 0x02
14
#define MSG_PEEK 0x02
Line 15... Line -...
15
#define MSG_DONTWAIT 0x40
-
 
16
 
-
 
17
dword errorcode;
15
#define MSG_DONTWAIT 0x40
18
 
16
 
19
struct 	sockaddr_in
17
struct 	SockAddr
20
{
-
 
21
        word    sin_family; 
-
 
22
        word    sin_port; 
18
{
23
        dword   sin_addr;
19
  word    sin_family;
Line -... Line 20...
-
 
20
  char    data[14];
-
 
21
};
-
 
22
 
24
        char    padding[8];
23
// ecx = domain
25
};  
24
// edx = type
26
 
-
 
27
inline fastcall dword Socket(ECX, EDX, ESI)
25
// esi = protocol
28
{
26
inline fastcall dword socket_open(ECX, EDX, ESI)
29
	$push	ebx
27
{
30
	$mov 	eax, 75
-
 
31
	$mov 	ebx, 0
-
 
32
	$int 	0x40
28
	$mov 	eax, 75
Line -... Line 29...
-
 
29
	$mov 	bl, 0
33
	errorcode = EBX;
30
	$int 	0x40
34
	$pop	ebx
31
}
35
} 
-
 
36
 
32
 
37
inline fastcall dword Close(ECX)
33
// ecx = socket number
38
{
34
inline fastcall dword socket_close(ECX)
39
	$push	ebx
-
 
40
	$mov 	eax, 75
-
 
41
	$mov 	ebx, 1
35
{
Line -... Line 36...
-
 
36
	$mov 	eax, 75
-
 
37
	$mov 	bl, 1
-
 
38
	$int 	0x40
42
	$int 	0x40
39
}
43
	errorcode = EBX;
40
 
44
	$pop	ebx	
-
 
45
}
41
// ecx = socket number
46
 
42
// edx = pointer to sockaddr structure
47
inline fastcall dword Bind(ECX, EDX, ESI)
43
// esi = length of sockaddr structure
48
{
-
 
49
	$push	ebx
-
 
50
	$mov 	eax, 75
44
inline fastcall dword socket_bind(ECX, EDX, ESI)
Line -... Line 45...
-
 
45
{
-
 
46
	$mov 	eax, 75
51
	$mov 	ebx, 2
47
	$mov 	bl, 2
52
	$int 	0x40
48
	$int 	0x40
53
	errorcode = EBX;
-
 
54
	$pop	ebx
49
}
55
}
50
 
56
 
51
// ecx = socket number
57
inline fastcall dword Listen(ECX, EDX)
-
 
58
{
-
 
59
	$push	ebx
52
// edx = backlog
Line -... Line 53...
-
 
53
inline fastcall dword socket_listen(ECX, EDX)
-
 
54
{
-
 
55
	$mov 	eax, 75
60
	$mov 	eax, 75
56
	$mov 	bl, 3
61
	$mov 	ebx, 3
57
	$int 	0x40
62
	$int 	0x40
-
 
63
	errorcode = EBX;
58
}
64
	$pop	ebx
59
 
65
}
60
// ecx = socket number
66
 
-
 
67
inline fastcall dword Connect(ECX, EDX, ESI)
-
 
68
{
61
// edx = pointer to sockaddr structure
Line -... Line 62...
-
 
62
// esi = length of sockaddr structure
-
 
63
inline fastcall dword socket_connect(ECX, EDX, ESI)
-
 
64
{
69
	$push	ebx
65
	$mov 	eax, 75
70
	$mov 	eax, 75
66
	$mov 	bl, 4
71
	$mov 	ebx, 4
-
 
72
	$int 	0x40
67
	$int 	0x40
73
	errorcode = EBX;
68
}
74
	$pop	ebx
69
 
75
}
-
 
76
 
-
 
77
inline fastcall dword Accept(ECX, EDX, ESI)
70
// ecx = socket number
Line -... Line 71...
-
 
71
// edx = pointer to sockaddr structure
-
 
72
// esi = length of sockaddr structure
-
 
73
inline fastcall dword socket_accept(ECX, EDX, ESI)
-
 
74
{
78
{
75
	$mov 	eax, 75
79
	$push	ebx
76
	$mov 	bl, 5
80
	$mov 	eax, 75
-
 
81
	$mov 	ebx, 5
77
	$int 	0x40
82
	$int 	0x40
78
}
83
	errorcode = EBX;
79
 
84
	$pop	ebx
-
 
85
}
-
 
86
 
80
// ecx = socket number
Line -... Line 81...
-
 
81
// edx = pointer to buffer
-
 
82
// esi = length of buffer
-
 
83
// edi = flags
-
 
84
inline fastcall dword socket_send(ECX, EDX, ESI, EDI)
87
inline fastcall dword Send(ECX, EDX, ESI, EDI)
85
{
88
{
86
	$mov 	eax, 75
89
	$push	ebx
-
 
90
	$mov 	eax, 75
87
	$mov 	bl, 6
91
	$mov 	ebx, 6
88
	$int 	0x40
92
	$int 	0x40
89
}
93
	errorcode = EBX;
-
 
94
	$pop	ebx
-
 
95
}
90
 
Line 96... Line 91...
96
 
91
// ecx = socket number
97
inline fastcall dword Receive(ECX, EDX, ESI, EDI)
92
// edx = pointer to buffer