Search Results

Search: Posts Made By: omega666
Forum: Programming 04-12-2011
1,643
Posted By omega666
For this question, this code isn't from a...
For this question, this code isn't from a program, i am just assuming the other parts are there, i just want to get the loop right. So just assume the rest is there. The question says just to write...
Forum: Programming 04-11-2011
1,643
Posted By omega666
Help with C programming
for a question like this

Assume you have a server with two clients and two child processes. The server retrieves data from the
children through a pipe (one each) and writes data to the clients...
Forum: Programming 04-11-2011
1,725
Posted By omega666
but in your code, your forking 10 times, but how...
but in your code, your forking 10 times, but how do you refer to ones u made before,

if I do this:
pid1=fork(); //first child has pid=0
if pid1>0 {
pid2=fork(); // second child has pid=0...
Forum: Programming 04-11-2011
1,725
Posted By omega666
so if a server creates 2 childs, how does it...
so if a server creates 2 childs, how does it tell, which child is which if both have a pid of 0?

---------- Post updated at 03:13 PM ---------- Previous update was at 03:12 PM ----------

in a...
Forum: Programming 04-11-2011
1,725
Posted By omega666
Question on pipes in C
If a code forks 2 childs, what can the values be for the process id's of each of the child? I child pid is supposed to be 0, but what if you fork 2 of them?
Forum: Programming 04-06-2011
3,087
Posted By omega666
How to decrease a string number by one in C?
If i have a macro called NUM which is "8" (string) for example
How do I make it into say "7", well i just want to lower it by one, also there will never be the case where its "0" and i have to...
Forum: Programming 04-06-2011
8,646
Posted By omega666
wouldnt this work, since strings are pointers? ...
wouldnt this work, since strings are pointers?
buf=buf+5;

and whats the difference between declaring a string like
char *buf;
and
char buf[10];

arent they both pointers? But in some cases...
Forum: Programming 04-06-2011
5,600
Posted By omega666
i got it now, it had to do with me mallocing in a...
i got it now, it had to do with me mallocing in a function to copy a string, seemed that solved the problem.
Forum: Programming 04-06-2011
3,319
Posted By omega666
if i have a child process going in a for loop...
if i have a child process going in a for loop doing a sleep command, there is no guarantee that it will die before the parent dies, but i know that eventually it will die, is it still safe to do...
Forum: Programming 04-05-2011
3,319
Posted By omega666
when parent process close, how to close the child?
can someone provide an example, where if the parent process quits for any reason, then the child process will also close?
Forum: Programming 04-04-2011
5,600
Posted By omega666
how do edit a node in a singly linked list in C?
If i have a linked list in C, how do I edit a node in it? Without ruining the whole list, by this i mean end up making it null or circular... (since it has to be linear and has to stop...
Forum: Programming 04-04-2011
1,472
Posted By omega666
how to check if something exists in a struct linked list?
can someone provide an example of a struct linked list, where it has strings as its values, and then how do I check if a specific string (say called buffer) exists in the list of structs?

i dont...
Forum: Programming 04-03-2011
8,646
Posted By omega666
help with string slicing in C
i have a string and i want the first 5 chars to be removed
this is what i have

void shift(char *string) {
int i;
for(i=0;i<5;i++) {
while(1) {
*string =...
Forum: Programming 04-02-2011
13,220
Posted By omega666
How to check if something exists in linked list in C?
i have a linked list set up like

typedef struct client_list {
char *client_name;
int client_socket_fd;
struct client_list *next;
} client;

client *client_list=NULL;
before...
Forum: Programming 04-02-2011
5,358
Posted By omega666
hmm, i got this to work the first time i use the...
hmm, i got this to work the first time i use the function, the second time always returns 0 for some reason

int already_there(client *client_list, char *username) {
if (client_list == NULL)...
Forum: Programming 04-01-2011
5,802
Posted By omega666
I think I got it now. ---------- Post...
I think I got it now.



---------- Post updated at 08:30 PM ---------- Previous update was at 06:34 PM ----------

i have another issue, then the client is running, and i press ctrl+c, it...
Forum: Programming 04-01-2011
5,802
Posted By omega666
so this should be able to tell me if it wrote...
so this should be able to tell me if it wrote properly?

void send_message(int client_socket_fd, char *message, int length) {
size_t bytes = write(client_socket_fd, message, length);
if...
Forum: Programming 04-01-2011
5,802
Posted By omega666
i just changed all of them to strlen, and the...
i just changed all of them to strlen, and the problem still occurs

---------- Post updated at 02:51 PM ---------- Previous update was at 02:34 PM ----------

how is read supposed to work, does...
Forum: Programming 04-01-2011
5,802
Posted By omega666
i dont understand, the only times i use that...
i dont understand, the only times i use that str_len is when the strings have no \n inside...



---------- Post updated at 02:21 PM ---------- Previous update was at 02:15 PM ----------

when...
Forum: Programming 04-01-2011
5,802
Posted By omega666
since my data can have >0 \n should i just change...
since my data can have >0 \n should i just change it to


int pos=0;
bzero(buffer,MAXDATASIZE); // Stop once we have an entire single line
while((buffer[pos] != '\0') && (pos < MAXDATASIZE))...
Forum: Programming 04-01-2011
5,802
Posted By omega666
your code is only reading one line (as in stops...
your code is only reading one line (as in stops at a \n), but my data that's being sent, can include more than 0 \n's, could that be causing the problem?
but then again, sometimes the problem...
Forum: Programming 04-01-2011
5,802
Posted By omega666
but how? if you read it waits until more data...
but how?
if you read it waits until more data comes in, so if you put a while loop, it will just go into an infinite loop?
so really if you read once, doesnt it read everything from the socket?, i...
Forum: Programming 04-01-2011
5,802
Posted By omega666
#include <stdio.h> #include <stdlib.h> ...
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>

#ifndef PORT...
Forum: Programming 04-01-2011
5,802
Posted By omega666
server #include "header.h" int main(int...
server

#include "header.h"
int main(int argc, char **argv) {
char buffer[MAXDATASIZE];
bzero(buffer, sizeof(buffer));
client *client_list=NULL; item *item_list=NULL;
...
Forum: Programming 04-01-2011
5,802
Posted By omega666
nvm i fixed it. ---------- Post updated at...
nvm i fixed it.

---------- Post updated at 09:09 PM ---------- Previous update was at 07:46 PM ----------

how does the select function code work? will it achieve a better result than what you...
Showing results 1 to 25 of 162

 
All times are GMT -4. The time now is 10:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy