Author: bdonlan
Date: 2004-12-30 22:18:02 -0500 (Thu, 30 Dec 2004)
New Revision: 486
Modified:
trunk/
trunk/clients/havercurs/net.c
trunk/clients/havercurs/net.h
Log:
[EMAIL PROTECTED]: bdonlan | 2004-12-31T03:17:11.150208Z
We connect now. Huzzah.
Property changes on: trunk
___________________________________________________________________
Name: svk:merge
- 1f59643a-e6e5-0310-bc24-f7d4c744f460:/haver/local/trunk:10237
27e50396-46e3-0310-8b22-ae223a1f35ce:/local:212
edfcd8bd-4ce7-0310-a97e-bb1efd40edf3:/local:238
+ 1f59643a-e6e5-0310-bc24-f7d4c744f460:/haver/local/trunk:10240
27e50396-46e3-0310-8b22-ae223a1f35ce:/local:212
edfcd8bd-4ce7-0310-a97e-bb1efd40edf3:/local:238
Modified: trunk/clients/havercurs/net.c
===================================================================
--- trunk/clients/havercurs/net.c 2004-12-31 03:00:30 UTC (rev 485)
+++ trunk/clients/havercurs/net.c 2004-12-31 03:18:02 UTC (rev 486)
@@ -3,6 +3,7 @@
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <string.h>
+#include <assert.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
@@ -12,10 +13,11 @@
/* FIXME: not actually async */
void net_async_connect(
net_conn_callback *cb, void *baton,
- const char *host, unsigned long port
+ const char *host, unsigned short port
)
{
struct hostent *h;
+ struct sockaddr_in addr;
int fd;
int pf;
int ret;
@@ -27,6 +29,9 @@
if (h->h_addrtype == AF_INET) {
pf = PF_INET;
} else {
+ /* FIXME: get ipv6 working */
+ cb(baton, -1, 0, "IPv6 address returned but not yet supported");
+ return;
pf = PF_INET6;
}
fd = socket(pf, SOCK_STREAM, 0);
@@ -34,7 +39,11 @@
cb(baton, -1, errno, strerror(errno));
return;
}
- ret = connect(fd, (const struct sockaddr *)h->h_addr_list[0],
h->h_length);
+ addr.sin_family = h->h_addrtype;
+ addr.sin_port = htons(port);
+ assert(h->h_length == sizeof addr.sin_addr);
+ memcpy(&addr.sin_addr, h->h_addr_list[0], h->h_length);
+ ret = connect(fd, (const struct sockaddr *)&addr, sizeof addr);
if (ret != 0) {
int err = errno;
close(fd);
Modified: trunk/clients/havercurs/net.h
===================================================================
--- trunk/clients/havercurs/net.h 2004-12-31 03:00:30 UTC (rev 485)
+++ trunk/clients/havercurs/net.h 2004-12-31 03:18:02 UTC (rev 486)
@@ -12,7 +12,7 @@
void net_async_connect(
net_conn_callback *cb, void *baton,
- const char *host, unsigned long port
+ const char *host, unsigned short port
);
#endif