[C] socket programming i'm stuck with that - Programming On Unix

Users browsing this thread: 2 Guest(s)
pvtmert
Members
here is my applications...

header: http://pub.iotek.org/p/AOrQrma
server app: http://pub.iotek.org/p/D2OUQ7o
client app: http://pub.iotek.org/p/z4uA4aL

the purpose is little file upload protocol that supports multiple files...
its like http... first computers negotiate with unix epoch time (for files' sake) then sends name/path of file... server recieves file then waits for next put header until no header left... then closes connection and exits from child...

server is getting stuck after forking...
client is working correctly, i tested with netcat...
Code:
Slax 7.0.8 (32-bits + PAE)
----- BEGIN GEEK CODE BLOCK-----
Version: 3.1
GE/CS/CM/S d+@ s-:- a--- C++++(++) UL+++ P+ L+++ E?() W+++(++) N? o? K- w+
O M-- V- PS+ PE Y? PGP- t+ 5? X++++(+++) R- !tv b+ DI? D- G e- h+ r-- z--
------END GEEK CODE BLOCK------
z3bra
Grey Hair Nixers
Isn't there a fork bomb ?

Code:
bool ischild = false;
while (!ischild)
    if (!ischild) {
        fork();
    }
}
xero
Long time nixers
(17-09-2014, 08:12 AM)z3bra Wrote: Isn't there a fork bomb ?

Code:
bool ischild = false;
while (!ischild)
    if (!ischild) {
        fork();
    }
}

yes. that is exactly what that code is.
as a simple example to get you thinking, you need to see how many files to upload and only make a single fork for each.

Code:
int count = 0;
int total = 3;
bool ischild = false;
while (!ischild)
    if (!ischild) {
        fork();
        count++;
        if(count < total) {
            ischild = true;
       }
    }
}
z3bra
Grey Hair Nixers
Good to see I'm not too rusty :P
pvtmert
Members
i havent looked here, i put that thing there because i didnt wanted to loop if there is child... it was in the middle of the work... anyway, i fixed everything and found my way through tutorials etc.

here is repository in github to improve and fix code:
https://github.com/pvtmert/uftp

thanks everyone