I've got a very frustrating error to debug right now. I'm using the following code to create a network socket in C++:
When I run this code, I get a segfault. I ran the program through gdb and got the following:
(line 63 being the socket call).
I've looked all over google, but seems like everyone else who has a problem like this actually is getting a segfault somewhere else in their code, rather then from the socket function itself.
I've used this code before (though it was a while ago), so I'm fairly sure it should work. Any ideas as to why I'm getting a segfault here?
Code:
60. int Network::openServerSocket(int portno) {
61. struct sockaddr_in serv_addr;
62.
63. int sockfd = socket(PF_INET, SOCK_STREAM, 0);
.....
When I run this code, I get a segfault. I ran the program through gdb and got the following:
Code:
Program received signal SIGSEGV, Segmentation fault.
0x08059210 in socket ()
(gdb) where
#0 0x08059210 in socket ()
#1 0x0805129f in Network::openServerSocket (portno=13546) at Network.cpp:63
I've looked all over google, but seems like everyone else who has a problem like this actually is getting a segfault somewhere else in their code, rather then from the socket function itself.
I've used this code before (though it was a while ago), so I'm fairly sure it should work. Any ideas as to why I'm getting a segfault here?