Hi~~all.
I am so sorry for asking questions so frequently!
While I compile my program,It shows the error as below.
gcc serv.c -o test
/tmp/ccaWzxh3.o: In function main': /tmp/ccaWzxh3.o(.text+0x1f): undefined reference to
socketā
collect2: ld returned 1 exit status
I have included the āsocket.hā file,But I donāt know what is the matter.
I also use another socket function like ālisten()ā to tset for compiling and i
it shows the same result.
Do I miss something ?
Here is my program.
#include <errno.h>
#include <sys/socket.h>
#include <sys/types.h>
int main(int argc , char *argv[]){
int errvalue;
int hSocket;
errno = EOK;
hSocket=socket( AF_INET,SOCK_STREAM,0 );
if(hSocket<0){
errvalue = errno;
printf( āThe error generated was %d\nā, errvalue );
printf( āThat means: %s\nā, strerror( errvalue ) );
return 1;
}
printf(āOpen socket successfully\nā);
close(hSocket);
return 1;
}