nixers
[C] socket programming i'm stuck with that - Printable Version
+- nixers (https://nixers.net)
+-- Forum: Development & Graphics (https://nixers.net/Forum-Development-Graphics)
+--- Forum: Programming On Unix (https://nixers.net/Forum-Programming-On-Unix)
+--- Thread: [C] socket programming i'm stuck with that (/Thread-C-socket-programming-i-m-stuck-with-that)


[C] socket programming i'm stuck with that - pvtmert - 17-09-2014

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...


RE: [C] socket programming i'm stuck with that - z3bra - 17-09-2014

Isn't there a fork bomb ?

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



RE: [C] socket programming i'm stuck with that - xero - 17-09-2014

(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;
       }
    }
}



RE: [C] socket programming i'm stuck with that - z3bra - 17-09-2014

Good to see I'm not too rusty :P


RE: [C] socket programming i'm stuck with that - pvtmert - 20-09-2014

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