tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
* [S] Socket problem/query
@ 1996-06-03 14:30 grscott
  0 siblings, 0 replies; only message in thread
From: grscott @ 1996-06-03 14:30 UTC (permalink / raw)
  To: tru64-unix-managers

My sincere thanks is extended to Dale Cook of Scientech, Inc, who quickly and 
accurately observed that I had neglected to include one important statement:
"serveraddr.sin_family = AF_INET" along with setting the sin_port 
appropriately. The fact that it worked on any platform was, I'd imagine, merely
coincidental!

My original whimper was:

>I've got a program which executes correctly on Sun & HP platforms but fails
>on my Alpha (3.2d) with "Address family not supported by protocol family"
>error.  Since there is an appropriate entry in /etc/services, I don't know
>what the complaint is.  I'm enclosing a short snippet which I hope is
>sufficient to enable those more knowledgeable than I to diagnose the problem!
>----------------------------------------------------------------------------
>  if ((p_data = getprotobyname("tcp")) == (struct protoent *)NULL)
>     barf("Got serious problems here!");
>  else printf("Found TCP with name \"%s\" and value %d\n",
>               p_data->p_name, p_data->p_proto);
>
>  if ((sockfd = socket(AF_INET, SOCK_STREAM, p_data->p_proto)) < 0)
>     barf("Socket Create Failed!");
>
>  if (ugw  = getservbyname("ugw_strm_int", "tcp"))
>   printf("Service is \"%s\" on port %d using protocol \"%s\"\n",
>           ugw->s_name, ntohs(ugw->s_port), ugw->s_proto);
>  else barf("UGW not available");
>
>  if (gw_host = gethostbyname(theirname))
>  {
>    memcpy( (char *)&(serveraddr.sin_addr.s_addr), gw_host->h_addr,
>            gw_host->h_length);
>    serveraddr.sin_port = ugw->s_port;
>    if (connect(sockfd, &serveraddr, sizeof(serveraddr)) < 0)
>       barf("Socket Connect Failed!");
>       // and here is indeed where it fails with the error
>    ... do_dah, do_dah...

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1996-06-03 14:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1996-06-03 14:30 [S] Socket problem/query grscott

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox