Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    begening network programming in linux

    HI I am starting to learnig network programming using ubuntu.
    I have learnt some basic concepts .
    I am now trying to build a simple socket.I learnt dat after creating a simple socket we have to bind it some socket I have the following code but I cant quite get this
    1.wat is bzero function
    2.sizeof function

    int bind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen);
    /* retrieve the port number for listening
    simplePort = atoi(argv[1]);
    /* set up the address structure */
    /* use INADDR_ANY to bind to all local addresses */
    /* note use of htonl() and htons() */
    bzero(&simpleServer, sizeof(simpleServer));
    simpleServer.sin_family = AF_INET;
    simpleServer.sin_addr.s_addr = htonl(INADDR_ANY);
    Chapter 2
    simpleServer.sin_port = htons(simplePort);
    bind to the address and port with our socket
    returnStatus = bind(simpleSocket,
    (struct sockaddr *)&simpleServer,
    if (returnStatus == 0) {
    fprintf(stderr, "Bind completed!\n");
    else {
    fprintf(stderr, "Could not bind to address!\n");

  2. #2
    Linux Engineer GNU-Fan's Avatar
    Join Date
    Mar 2008
    Quote Originally Posted by manish411 View Post
    1.wat is bzero function
    man page bzero section 3

    Quote Originally Posted by manish411 View Post
    2.sizeof function
    C++ Reference [C++ Reference]
    Debian GNU/Linux -- You know you want it.

  3. #3
    bzero is a function that initializes the structure to zero.
    sizeof is the another function which calculates the size of the structure.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts