View Single Post
Old Sep 7th, 2007, 8:52 AM   #1
boraciner
Programmer
 
boraciner's Avatar
 
Join Date: Nov 2005
Location: Turkey
Posts: 93
Rep Power: 3 boraciner is on a distinguished road
Basic Socket Programming Error in Linux.. Pls help

Hi! I don't have experiance in linux C programming. I took a linux socket programming book and tried the first example code but It didn't work. I use these codes.. please help me!
Thanks for your replies

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
int
main(int argc,char **argv) {
    int z;                   /* Status return code */
    int s[2];                /* Pair of sockets */
    /*
      * Create a pair of local sockets:
      */
    z = socketpair(AF_LOCAL,SOCK_STREAM,0,s);
    if ( z == -1 ) {
         fprintf(stderr,
             “%s: socketpair(AF_LOCAL,SOCK_STREAM,0)\n”,
             strerror(errno));
         return 1;           /* Failed */
    }
    /*
      * Report the socket file descriptors returned:
      */
    printf(“s[0] = %d;\n”,s[0]);
    printf(“s[1] = %d;\n”,s[1]);
    system(“netstat --unix -p”);
    return 0;
}


Error Message:

bora.c: In function ‘main’:
bora.c:18: error: stray ‘\342’ in program
bora.c:18: error: stray ‘\200’ in program
bora.c:18: error: stray ‘\234’ in program
bora.c:18: error: expected expression before ‘%’ token
bora.c:18: error: stray ‘\’ in program
bora.c:18: error: stray ‘\342’ in program
bora.c:18: error: stray ‘\200’ in program
bora.c:18: error: stray ‘\235’ in program
bora.c:25: error: stray ‘\342’ in program
bora.c:25: error: stray ‘\200’ in program
bora.c:25: error: stray ‘\234’ in program
bora.c:25: error: expected expression before ‘%’ token
bora.c:25: error: stray ‘\’ in program
bora.c:25: error: stray ‘\342’ in program
bora.c:25: error: stray ‘\200’ in program
bora.c:25: error: stray ‘\235’ in program
bora.c:26: error: stray ‘\342’ in program
bora.c:26: error: stray ‘\200’ in program
bora.c:26: error: stray ‘\234’ in program
bora.c:26: error: expected expression before ‘%’ token
bora.c:26: error: stray ‘\’ in program
bora.c:26: error: stray ‘\342’ in program
bora.c:26: error: stray ‘\200’ in program
bora.c:26: error: stray ‘\235’ in program
bora.c:27: error: stray ‘\342’ in program
bora.c:27: error: stray ‘\200’ in program
bora.c:27: error: stray ‘\234’ in program
bora.c:27: error: ‘netstat’ undeclared (first use in this function)
bora.c:27: error: (Each undeclared identifier is reported only once
bora.c:27: error: for each function it appears in.)
bora.c:27: error: expected ‘)’ before numeric constant
bora.c:27: error: stray ‘\342’ in program
bora.c:27: error: stray ‘\200’ in program
bora.c:27: error: stray ‘\235’ in program



I used this command to compile

 gcc bora.c -o bora `pkg-config --cflags --libs gtk+-2.0`
boraciner is offline   Reply With Quote