* RE: Where are the socket libraries?
@ 2000-12-08 11:33 Anderjaska, John
0 siblings, 0 replies; 6+ messages in thread
From: Anderjaska, John @ 2000-12-08 11:33 UTC (permalink / raw)
To: 'Robert Nail', Alexandre Oliva; +Cc: gcc-help
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Where are the socket libraries?
2000-12-08 6:56 ` Robert Nail
@ 2000-12-08 13:20 ` Alexandre Oliva
0 siblings, 0 replies; 6+ messages in thread
From: Alexandre Oliva @ 2000-12-08 13:20 UTC (permalink / raw)
To: Robert Nail; +Cc: gcc-help
On Dec 8, 2000, "Robert Nail" <robert.nail@entact.net> wrote:
> 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
serv is a pointer, so use `->' instead of `.'.
--
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Where are the socket libraries?
2000-12-07 8:36 ` Alexandre Oliva
@ 2000-12-08 6:56 ` Robert Nail
2000-12-08 13:20 ` Alexandre Oliva
0 siblings, 1 reply; 6+ messages in thread
From: Robert Nail @ 2000-12-08 6:56 UTC (permalink / raw)
To: Alexandre Oliva; +Cc: gcc-help
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Where are the socket libraries?
2000-12-07 7:24 ` Where are the socket libraries? Robert Nail
2000-12-07 8:36 ` Alexandre Oliva
@ 2000-12-07 21:11 ` Curtis R Anderson
1 sibling, 0 replies; 6+ messages in thread
From: Curtis R Anderson @ 2000-12-07 21:11 UTC (permalink / raw)
To: Robert Nail; +Cc: gcc-help
Robert Nail wrote:
>
> I try to link a simple socket program for Linux 6.0 but it can't find the
> SOCKADDR structure. Any ideas would be appreciated.
Try:
#include <sys/socket.h>
--
Curtis R. Anderson, Co-creator of "Gleepy the Hen", SP 2.5?, KoX
No digital wireless, no xDSL, no pagers. Keeps the riff-raff out.
http://www.madbbs.com/users/gleepy/ ICQ: 50137888
mailto:gleepy@intelligencia.com UTM: PS 7036 7315, zone 17
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Where are the socket libraries?
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-07 21:11 ` Curtis R Anderson
1 sibling, 1 reply; 6+ messages in thread
From: Alexandre Oliva @ 2000-12-07 8:36 UTC (permalink / raw)
To: Robert Nail; +Cc: gcc-help
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Where are the socket libraries?
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 ` Robert Nail
2000-12-07 8:36 ` Alexandre Oliva
2000-12-07 21:11 ` Curtis R Anderson
0 siblings, 2 replies; 6+ messages in thread
From: Robert Nail @ 2000-12-07 7:24 UTC (permalink / raw)
To: gcc-help
I try to link a simple socket program for Linux 6.0 but it can't find the
SOCKADDR structure. Any ideas would be appreciated.
Thanks
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2000-12-08 13:20 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-12-08 11:33 Where are the socket libraries? Anderjaska, John
-- 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
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).