-   Linux - Networking (
-   -   linux networking question (

knightstar 04-28-2002 07:56 PM

linux networking question
I have been racking my brain for the last couple of days to find an answer to this question, so here it is:

I am building a networking application (using poll()). I first wanted to figure out how poll worked, so I wrote some test code (very short). It segment faults whenever I run it, and I can't figure out why. I have tried it on several other distros, and flavors of *nix, including my universitys DIGITAL system with no luck.

------Here is my code-----------------------

#include <stdio.h>
#include <poll.h>
#include <stdlib.h>

struct ClientData {
char buffer[8192];

int main() {

pollfd ClientFds[1024];
ClientData socketdata[1024];

for (int x=0;x<1024;x++) {
ClientFds[x].fd = -1;
return 0;

any help would be greatly appreciated.

--------end of code-------

Mik 04-29-2002 06:40 AM

Use malloc and free when you want to allocate large amounts of memory. You are trying to get a block of 8MB's by creating an array of ClientData.

All times are GMT -5. The time now is 04:13 AM.