Commit 1a792e3e authored by Dafydd Harries's avatar Dafydd Harries

give UDPSocket an address instead of just a port

darcs-hash:20070120051357-c9803-f23e8f6b9bb73946868b9de76c0e05457c863858.gz
parent 42f34e18
......@@ -69,8 +69,7 @@ socket_manager_init_socket (
struct sockaddr_in *sin)
{
gint sockfd;
struct sockaddr_in name;
guint name_len = sizeof (name);
guint name_len = sizeof (struct sockaddr_in);
sockfd = socket (PF_INET, SOCK_DGRAM, 0);
......@@ -84,14 +83,13 @@ socket_manager_init_socket (
return FALSE;
}
if (getsockname (sockfd, (struct sockaddr *) &name, &name_len) != 0)
if (getsockname (sockfd, (struct sockaddr *) &(sock->addr), &name_len) != 0)
{
close (sockfd);
return FALSE;
}
sock->fileno = sockfd;
sock->port = ntohs (name.sin_port);
sock->send = socket_send;
sock->recv = socket_recv;
sock->close = socket_close;
......
......@@ -6,8 +6,8 @@ typedef struct _UDPSocket UDPSocket;
struct _UDPSocket
{
struct sockaddr_in addr;
guint fileno;
guint port;
gint (*recv) (UDPSocket *sock, struct sockaddr_in *from, guint len,
gchar *buf);
gboolean (*send) (UDPSocket *sock, struct sockaddr_in *to, guint len,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment