Rev 5904 | Rev 7006 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5904 | Rev 6921 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
2 | ;; ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2017. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;; HTTP library for KolibriOS ;; |
6 | ;; HTTP library for KolibriOS ;; |
7 | ;; ;; |
7 | ;; ;; |
8 | ;; Written by hidnplayr@kolibrios.org ;; |
8 | ;; Written by hidnplayr@kolibrios.org ;; |
Line 1461... | Line 1461... | ||
1461 | .no_proxy: |
1461 | .no_proxy: |
Line 1462... | Line 1462... | ||
1462 | 1462 | ||
1463 | ; Resolve the hostname |
1463 | ; Resolve the hostname |
1464 | DEBUGF 1, "Resolving hostname\n" |
1464 | DEBUGF 1, "Resolving hostname\n" |
1465 | push esp ; reserve stack place |
- | |
1466 | push esp ; fourth parameter |
- | |
1467 | push 0 ; third parameter |
- | |
1468 | push 0 ; second parameter |
- | |
1469 | push [hostname] |
1465 | push esp ; reserve stack place |
1470 | call [getaddrinfo] |
1466 | invoke getaddrinfo, [hostname], 0, 0, esp |
1471 | pop esi |
1467 | pop esi |
1472 | test eax, eax |
1468 | test eax, eax |
Line 1473... | Line 1469... | ||
1473 | jnz .error1 |
1469 | jnz .error1 |
Line 1487... | Line 1483... | ||
1487 | mov [esi + sockaddr_in.sin_family], AF_INET4 |
1483 | mov [esi + sockaddr_in.sin_family], AF_INET4 |
1488 | mov eax, [port] |
1484 | mov eax, [port] |
1489 | xchg al, ah |
1485 | xchg al, ah |
1490 | mov [esi + sockaddr_in.sin_port], ax |
1486 | mov [esi + sockaddr_in.sin_port], ax |
Line 1491... | Line 1487... | ||
1491 | 1487 | ||
1492 | ; Connect to the server. |
1488 | ; Open a new TCP socket |
1493 | mcall socket, AF_INET4, SOCK_STREAM, 0 |
1489 | mcall socket, AF_INET4, SOCK_STREAM, 0 |
1494 | test eax, eax |
1490 | test eax, eax |
1495 | jz .error2 |
1491 | jz .error3 |
1496 | mov [socketnum], eax |
1492 | mov [socketnum], eax |
Line -... | Line 1493... | ||
- | 1493 | DEBUGF 1, "Socket: 0x%x\n", eax |
|
1497 | DEBUGF 1, "Socket: 0x%x\n", eax |
1494 | |
1498 | 1495 | ; Connect to the server |
|
1499 | mcall connect, [socketnum], [sockaddr], 18 |
1496 | mcall connect, [socketnum], [sockaddr], 18 |
1500 | test eax, eax |
1497 | test eax, eax |
Line 1501... | Line -... | ||
1501 | jnz .error2 |
- | |
1502 | DEBUGF 1, "Socket is now connected.\n" |
1498 | jnz .error3 |
1503 | 1499 | DEBUGF 1, "Socket is now connected.\n" |
|
1504 | ; free allocated memory |
1500 | |
Line -... | Line 1501... | ||
- | 1501 | invoke freeaddrinfo ; Free allocated memory |
|
- | 1502 | mov eax, [socketnum] |
|
- | 1503 | ret |
|
- | 1504 | ||
- | 1505 | .error3: |
|
- | 1506 | DEBUGF 2, "Could not connect to the remote server\n" |
|
1505 | call [freeaddrinfo] |
1507 | invoke freeaddrinfo ; Free allocated memory |
- | 1508 | xor eax, eax |
|
1506 | mov eax, [socketnum] |
1509 | ret |
1507 | ret |
1510 | |
- | 1511 | .error2: |
|
- | 1512 | DEBUGF 2, "Resolving hostname failed\n" |
|
1508 | 1513 | invoke freeaddrinfo ; Free allocated memory |
|
- | 1514 | xor eax, eax |
|
1509 | .error2: |
1515 | ret |
1510 | ; free allocated memory |
1516 | |
Line 1511... | Line 1517... | ||
1511 | call [freeaddrinfo] |
1517 | .error1: |