View Single Post
  #2   (View Single Post)  
Old 3rd June 2009
BSDfan666 BSDfan666 is offline
Real Name: N/A, this is the interweb.
Helpful companion
 
Join Date: Apr 2008
Location: Ontario, Canada
Posts: 2,223
Default

I hardly believe that this compiles anywhere, for one..
  • You're naming your local variable socket.. it clashes with the name of the socket function.
  • You populate a few elements of the sockaddr_in structure, but don't do anything with it.
Code:
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>

#define PORT 13

int main( void )
{
    int sock = socket( AF_INET, SOCK_STREAM, 0 );
    struct sockaddr_in address;

    address.sin_family = AF_INET;
    address.sin_port = PORT;

    puts( "\nInitialization complete.\n" );

    return 0;
}
It should at least compile now, but it's not exactly doing much of anything...

Helpful links:
http://beej.us/guide/bgnet/
Reply With Quote