From: Bill Cunningham on
I tried this just to see what would happen and it didn't compile. Here
are my error codes,

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

int tcp, bstat;
tcp = socket(tcp, SOCK_STREAM, 0);
bstat = bind(tcp, INADDR_ANY, 4096);
int main()
{
if (tcp == -1) {
perror("tcp error");
return 1;
}
if (bstat == -1) {
perror("bind error");
return 1;
}
return 0;
}
p.c:5: error: initializer element is not constant
p.c:5: warning: data definition has no type or storage class
p.c:6: error: `INADDR_ANY' undeclared here (not in a function)
p.c:6: error: initializer element is not constant
p.c:6: warning: data definition has no type or storage class

I haven't got my book so I'm reading man pages and online tutorials so
far.

Bill



From: Noob on
Bill Cunningham wrote:

> I haven't got my book so I'm reading man pages and online tutorials so far.

Try Beej's Guide to Network Programming
http://beej.us/guide/bgnet/
From: Scott Lurndal on
"Bill Cunningham" <nospam(a)nspam.invalid> writes:
> I tried this just to see what would happen and it didn't compile. Here
>are my error codes,
>
>#include <stdio.h>
>#include <sys/socket.h>
>
>int tcp, bstat;
>tcp = socket(tcp, SOCK_STREAM, 0);
>bstat = bind(tcp, INADDR_ANY, 4096);
>int main()
>{
> if (tcp == -1) {
> perror("tcp error");
> return 1;
> }
> if (bstat == -1) {
> perror("bind error");
> return 1;
> }
> return 0;
>}
>p.c:5: error: initializer element is not constant
>p.c:5: warning: data definition has no type or storage class
>p.c:6: error: `INADDR_ANY' undeclared here (not in a function)
>p.c:6: error: initializer element is not constant
>p.c:6: warning: data definition has no type or storage class
>
> I haven't got my book so I'm reading man pages and online tutorials so
>far.
>
>Bill
>

You should learn "C" before you try sockets.

scott
From: Bill Cunningham on

"Noob" <root(a)127.0.0.1> wrote in message
news:hpfh46$8rv$1(a)speranza.aioe.org...
> Try Beej's Guide to Network Programming
> http://beej.us/guide/bgnet/
>
Ok Will do.


From: Bill Cunningham on

"Scott Lurndal" <scott(a)slp53.sl.home> wrote in message
news:O6Kun.92146$DU3.82888(a)news.usenetserver.com...
> You should learn "C" before you try sockets.

What do you mean? Do you mean I need to create instances of struct addr
and then use elements of structs and pointers like in the prototypes? I hope
it won't be that hard. If so I'll be learning alot about C.

Bill