diff options
Diffstat (limited to 'libbb/xconnect.c')
| -rw-r--r-- | libbb/xconnect.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/libbb/xconnect.c b/libbb/xconnect.c index 9e771495d..f3a1b4462 100644 --- a/libbb/xconnect.c +++ b/libbb/xconnect.c | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | * | 6 | * |
| 7 | */ | 7 | */ |
| 8 | 8 | ||
| 9 | #include "inet_common.h" | ||
| 10 | #include <unistd.h> | 9 | #include <unistd.h> |
| 11 | #include <string.h> | 10 | #include <string.h> |
| 12 | #include <stdlib.h> | 11 | #include <stdlib.h> |
| @@ -58,7 +57,7 @@ int xconnect(const char *host, const char *port) | |||
| 58 | struct sockaddr_in s_addr; | 57 | struct sockaddr_in s_addr; |
| 59 | int s = socket(AF_INET, SOCK_STREAM, 0); | 58 | int s = socket(AF_INET, SOCK_STREAM, 0); |
| 60 | struct servent *tserv; | 59 | struct servent *tserv; |
| 61 | int port_nr=atoi(port); | 60 | int port_nr=htons(atoi(port)); |
| 62 | struct hostent * he; | 61 | struct hostent * he; |
| 63 | 62 | ||
| 64 | if (port_nr==0 && (tserv = getservbyname(port, "tcp")) != NULL) | 63 | if (port_nr==0 && (tserv = getservbyname(port, "tcp")) != NULL) |
| @@ -66,7 +65,7 @@ int xconnect(const char *host, const char *port) | |||
| 66 | 65 | ||
| 67 | memset(&s_addr, 0, sizeof(struct sockaddr_in)); | 66 | memset(&s_addr, 0, sizeof(struct sockaddr_in)); |
| 68 | s_addr.sin_family = AF_INET; | 67 | s_addr.sin_family = AF_INET; |
| 69 | s_addr.sin_port = htons(port_nr); | 68 | s_addr.sin_port = port_nr; |
| 70 | 69 | ||
| 71 | he = xgethostbyname(host); | 70 | he = xgethostbyname(host); |
| 72 | memcpy(&s_addr.sin_addr, he->h_addr, sizeof s_addr.sin_addr); | 71 | memcpy(&s_addr.sin_addr, he->h_addr, sizeof s_addr.sin_addr); |
