public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Anderjaska, John" <john.anderjaska@Teligent.com>
To: "'Robert Nail'" <robert.nail@entact.net>,
	Alexandre Oliva <aoliva@redhat.com>
Cc: gcc-help@gcc.gnu.org
Subject: RE: Where are the socket libraries?
Date: Fri, 08 Dec 2000 11:33:00 -0000	[thread overview]
Message-ID: <C1AD7DC4C16ED211A82B00A0C9EA52A401EC99F6@re0ma002.teligent.net> (raw)

Hi,

I'll put in my 2 cents on this one.  First of all I don't think
"333.444.555.6" is a valid IP address.  There may be a conversion problem
w/inet_addr.  Also I suspect your assignments of 'serv'.  It also appears
that you did not setup the transport end point.  You might try this:

#include <sys/socket.h>
#include <netinet/in.h>
#define SvrSocketNo 777
#define SIZE sizeof(struct sockaddr_in)

int sockfd;
char c;

struct sockaddr_in server = {AF_INET, SvrSocketNo};
sockfd = (int)socket(AF_INET, SOCK_STREAM,0);
connect(sockfd, (struct sockaddr *)&server, SIZE);
.
.
.
len = send(sockfd, &c, 1, 0);
**************************************************

Good Luck .. John

*************************************************

The source I have is below:

The error messages I get when trying to gcc this stuff is:

request for member "sin_family" in something not a structure or union
request for member "sin_addr" in something not a structure or union
request for member "sin_port" in something not a structure or union

The only place I can find sin_family and such is on /usr/include/linux/in.h.
I have tried to include <linux/in.h> but it makes no difference.  All help
will be appreciated.  Thanks

#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>


main()
{
 int i,j;
 int sock1;
 char ibuf[BUFSIZ];

 struct sockaddr *serv;
 memset(&serv,0,sizeof(serv));

 serv.sin_family = AF_INET;
 serv.sin_addr.s_addr = inet_addr("333.444.555.6");
 serv.sin_port = htons(777);

 if(connect(sock1, (struct sockaddr*) &serv,sizeof(serv)) < 0)
  printf("Error on connect\n");

 i = write(sock1,"This is test1",13);
 i = read(sock1,ibuf,20);
 printf("Ibuf: %s\n",ibuf);
}


----- Original Message -----
From: "Alexandre Oliva" <aoliva@redhat.com>
To: "Robert Nail" <robert.nail@entact.net>
Cc: <gcc-help@gcc.gnu.org>
Sent: Thursday, December 07, 2000 10:36 AM
Subject: Re: Where are the socket libraries?


> On Dec  7, 2000, "Robert Nail" <robert.nail@entact.net> wrote:
>
> > I try to link a simple socket program for Linux 6.0 but it can't find
the
> > SOCKADDR structure.
>
> This will list the header files you may have to include to get its
> definition:
>
> grep -l -r SOCKADDR /usr/include
>
> Then, you may have to link your program with some libraries (!= header
> files) to get definitions of whatever functions you use.
>
> --
> Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
> Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
> CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
> Free Software Evangelist    *Please* write to mailing lists, not to me

             reply	other threads:[~2000-12-08 11:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-12-08 11:33 Anderjaska, John [this message]
  -- strict thread matches above, loose matches on Subject: below --
2000-12-07  6:16 [A] It works! : How to create objects of a class defined in .so file? Rajesh Lolam
2000-12-07  7:24 ` Where are the socket libraries? Robert Nail
2000-12-07  8:36   ` Alexandre Oliva
2000-12-08  6:56     ` Robert Nail
2000-12-08 13:20       ` Alexandre Oliva
2000-12-07 21:11   ` Curtis R Anderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=C1AD7DC4C16ED211A82B00A0C9EA52A401EC99F6@re0ma002.teligent.net \
    --to=john.anderjaska@teligent.com \
    --cc=aoliva@redhat.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=robert.nail@entact.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).