Hi
I wrote a simple server in C and it seems like the functions are executed in the wrong order or something. (btw I'm on linux (ubuntu:hoary) if that matters anything in this case)

it goes like this:
Code:
...socket()...bind()...

if(listen(sfd, 10) == -1) { //sfd = main socket
	printf("\nFailed on listen(): Terminating!");
	exit(1); 
}
printf("\nServer established---");

while(1) { //A loop to accept incoming connections
	cfd = accept(sfd, (struct sockaddr *)&client, &sin_size);
	printf("\nIncoming connection");
...
The program compiles and runs fine...

So this should print "Server established" and then start accepting incoming connections but instead
it enters the while() loop, waits until accept() returns for the first time and THEN prints "Server established" (but no "incoming connection")

what's up with this