Rev 5708 | Rev 5720 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5708 | Rev 5715 | ||
---|---|---|---|
Line 14... | Line 14... | ||
14 | 14 | ||
Line 15... | Line 15... | ||
15 | thread_start: |
15 | thread_start: |
Line -... | Line 16... | ||
- | 16 | ||
- | 17 | mcall 40, 0 ; disable all events for this thread |
|
- | 18 | ||
- | 19 | ; Extract port number from server address |
|
- | 20 | mov esi, serveraddr |
|
- | 21 | @@: |
|
- | 22 | lodsb |
|
- | 23 | test al, al |
|
- | 24 | jz .port_done |
|
- | 25 | cmp al, ':' |
|
- | 26 | jne @r |
|
- | 27 | mov byte[esi-1], 0 ; replace colon with 0 byte, we dont want to upset getaddrinfo |
|
- | 28 | xor eax, eax |
|
- | 29 | xor ebx, ebx ; port number |
|
- | 30 | @@: |
|
- | 31 | lodsb |
|
- | 32 | test al, al |
|
- | 33 | jz @f |
|
- | 34 | sub al, '0' |
|
- | 35 | jb err_dns |
|
- | 36 | cmp al, 9 |
|
- | 37 | ja err_dns |
|
- | 38 | lea ebx, [ebx*4+ebx] |
|
- | 39 | lea ebx, [ebx*2+eax] |
|
- | 40 | jmp @b |
|
- | 41 | @@: |
|
- | 42 | xchg bl, bh |
|
16 | 43 | mov [sockaddr1.port], bx |
|
17 | mcall 40, 0 ; disable all events for this thread |
44 | .port_done: |
18 | 45 | ||
19 | ; resolve name |
46 | ; Resolve hostname |
20 | push esp ; reserve stack place |
- | |
21 | invoke getaddrinfo, serveraddr, 0, 0, esp |
47 | push esp ; reserve stack place |
22 | pop esi |
48 | invoke getaddrinfo, serveraddr, 0, 0, esp |
Line 23... | Line 49... | ||
23 | ; test for error |
49 | pop esi |
24 | test eax, eax |
50 | test eax, eax |
25 | jnz err_dns |
51 | jnz err_dns |
- | 52 | ||
Line 26... | Line 53... | ||
26 | 53 | mov eax, [esi+addrinfo.ai_addr] |
|
27 | mov eax, [esi+addrinfo.ai_addr] |
54 | mov eax, [eax+sockaddr_in.sin_addr] |
28 | mov eax, [eax+sockaddr_in.sin_addr] |
55 | mov [sockaddr1.ip], eax |
Line 29... | Line 56... | ||
29 | mov [sockaddr1.ip], eax |
56 | invoke freeaddrinfo, esi |
30 | - | ||
31 | DEBUGF 1, "Connecting to %u.%u.%u.%u:%u\n", \ |
57 | |
32 | [sockaddr1.ip]:1, [sockaddr1.ip+1]:1, [sockaddr1.ip+2]:1, [sockaddr1.ip+3]:1, \ |
58 | DEBUGF 1, "Connecting to %u.%u.%u.%u:%u\n", \ |
33 | [sockaddr1.port]:2 |
59 | [sockaddr1.ip]:1, [sockaddr1.ip+1]:1, [sockaddr1.ip+2]:1, [sockaddr1.ip+3]:1, \ |
34 | - | ||
35 | invoke freeaddrinfo, esi |
60 | [sockaddr1.port]:2 |
- | 61 | ||
- | 62 | ; Open socket |
|
36 | 63 | mcall socket, AF_INET4, SOCK_STREAM, 0 |
|
37 | mcall socket, AF_INET4, SOCK_STREAM, 0 |
64 | cmp eax, -1 |
38 | cmp eax, -1 |
65 | je err_sock |
Line -... | Line 66... | ||
- | 66 | mov [socketnum], eax |
|
39 | je err_sock |
67 | |
40 | 68 | ; Connect to the server |
|
41 | mov [socketnum], eax |
- | |
42 | mcall connect, [socketnum], sockaddr1, 18 |
69 | mcall connect, [socketnum], sockaddr1, 18 |
43 | cmp eax, -1 |
70 | cmp eax, -1 |
- | 71 | je err_connect |
|
- | 72 | ||
44 | je err_connect |
73 | ; Wait for handshake from server |
45 | 74 | ; TODO: implement timeout |
|
46 | ; TODO: implement timeout |
75 | call wait_for_data |
Line 47... | Line 76... | ||
47 | call wait_for_data |
76 | cmp dword[receive_buffer], "RFB " |
Line 201... | Line 230... | ||
201 | mov [name.dash], "-" |
230 | mov [name.dash], "-" |
Line 202... | Line 231... | ||
202 | 231 | ||
203 | ; Tell the main thread we are ready for business! |
232 | ; Tell the main thread we are ready for business! |
Line 204... | Line 233... | ||
204 | mov [status], STATUS_CONNECTED |
233 | mov [status], STATUS_CONNECTED |
205 | 234 | ||
Line 206... | Line 235... | ||
206 | ; Request initial update |
235 | ; Request initial framebuffer update from server |
207 | mov [FramebufferUpdateRequest.inc], 0 |
236 | mov [FramebufferUpdateRequest.inc], 0 |
208 | 237 | ||
Line 267... | Line 296... | ||
267 | xchg al, ah |
296 | xchg al, ah |
268 | mov [rectangle.height], eax |
297 | mov [rectangle.height], eax |
Line 269... | Line 298... | ||
269 | 298 | ||
270 | lodsd ; encoding |
299 | lodsd ; encoding |
271 | bswap eax |
300 | bswap eax |
272 | DEBUGF 1, "rectangle: width=%u height=%u x=%u y=%u encoding: ",\ |
301 | DEBUGF 1, "Rectangle: x=%u y=%u width=%u height=%u encoding: ",\ |
Line 273... | Line 302... | ||
273 | [rectangle.width]:2, [rectangle.height]:2, [rectangle.x]:2, [rectangle.y]:2 |
302 | [rectangle.x]:2, [rectangle.y]:2, [rectangle.width]:2, [rectangle.height]:2 |
274 | 303 | ||
275 | cmp eax, 0 |
304 | cmp eax, 0 |
276 | je encoding_raw |
305 | je encoding_raw |