LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 04-28-2002, 07:56 PM   #1
knightstar
LQ Newbie
 
Registered: Apr 2002
Posts: 1

Rep: Reputation: 0
Question 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.


Knightstar
--------end of code-------
 
Old 04-29-2002, 06:40 AM   #2
Mik
Senior Member
 
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316

Rep: Reputation: 47
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
linux networking question m4dj4ck Linux - Networking 6 10-13-2004 09:21 AM
Slackware Linux 9.0 Networking Help (newbie question) Elimist Linux - Networking 1 11-15-2003 09:05 PM
Linux Networking Question/Problem tictocdoc Linux - Networking 4 10-17-2003 10:15 AM
Linux Networking 101 question CyberNet Linux - Networking 3 11-12-2002 06:53 AM
linux networking question jonathandavidso Linux - Networking 3 11-13-2001 01:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration