bind() error

Hello. I am havig problems with this program. It is a server supposed to get 2 integers from client, calculate a sum and send result back to client. I am getting a bind() error when attempting to execute it. Any help appreciated

#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <string.h>

int main (void)
{
  int sd, new_sd, sum;
  struct sockaddr_un serv_addr;

  struct mystruct
  {
    int addend;
    int augend;
  } values;

  void report_fatal_error (char *message);

  sd = socket (AF_UNIX, SOCK_STREAM, 0);

  if (sd == -1)
    report_fatal_error ("Server: Cannot open socket");

  bzero ((char *) &serv_addr, sizeof (serv_addr));

  serv_addr.sun_family = AF_UNIX;

  strcpy (serv_addr.sun_path, "/tmp/mysocket");

  if (bind (sd, (struct sockaddr *) &serv_addr, sizeof (serv_addr)) == -1)
    report_fatal_error ("Server: Binding error in local address");

  listen (sd, 5);

  while (1)
  {
    new_sd = accept (sd, NULL, 0);

    if (new_sd == -1)
      report_fatal_error ("Server: Accept error");

    read (new_sd, &values, sizeof (values));

    sum = values.addend + values.augend;

    printf ("server: %d + %d = %d\n", values.addend, values.augend, sum);

    write (new_sd, &sum, sizeof (sum));

    close (new_sd);
  }
}

void report_fatal_error (char *message)
{
  perror (message);

  exit (1);
}

Sorry m8 i am a little rusty on server programming but what port are u telling the server to bind to..??
U must bind it to a well know unreserved port greater than 1024
Sorry of i got this wrong but you would want to set up a portbase to connect to a porrt greater than 1024..
Have a look at comver voulume 3 C/S Programming *Excellent*
That will show u.!!

Mojo

Adding up to Mojo's reply.....

Pls try to print the errno/ err mesage that you get when you bind the socket. That will be more helpful in narrowing down your debugging.

Deepa