Skip to content

Instantly share code, notes, and snippets.

@josephruscio
Created August 29, 2009 03:23
Show Gist options
  • Save josephruscio/177373 to your computer and use it in GitHub Desktop.
Save josephruscio/177373 to your computer and use it in GitHub Desktop.
@@ -283,7 +283,10 @@ inet_connect(int s, const char *hname, uint16_t port)
{
struct addrinfo *lookup_result=NULL;
struct addrinfo hints;
- struct sockaddr_storage dest_addr;
+ union {
+ struct sockaddr_storage sa_stor;
+ struct sockaddr_in sa_in;
+ } dest_addr;
struct sockaddr_in *dest_in;
int v;
@@ -302,18 +305,19 @@ inet_connect(int s, const char *hname, uint16_t port)
}
- dest_in = (struct sockaddr_in *) &dest_addr;
+ dest_in = &dest_addr.sa_in;
dest_in->sin_port = htons(port);
connect(s, (struct sockaddr*) &dest_addr, sizeof(dest_addr));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment